package com.v1.video.activity;

import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnBufferingUpdateListener;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.media.MediaPlayer.OnSeekCompleteListener;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.format.DateUtils;
import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;

import com.iss.view.common.ToastAlone;
import com.iss.view.pulltorefresh.PullToRefreshBase;
import com.iss.view.pulltorefresh.PullToRefreshBase.Mode;
import com.iss.view.pulltorefresh.PullToRefreshBase.OnRefreshListener2;
import com.iss.view.pulltorefresh.PullToRefreshListView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import com.tencent.mm.sdk.modelmsg.SendMessageToWX;
import com.tencent.mm.sdk.modelmsg.WXMediaMessage;
import com.tencent.mm.sdk.modelmsg.WXVideoObject;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.umeng.analytics.MobclickAgent;
import com.v1.video.AppContext;
import com.v1.video.Constant;
import com.v1.video.R;
import com.v1.video.adapter.CommentAdapter;
import com.v1.video.domain.AddAlbumForVideoPageInfoEntity;
import com.v1.video.domain.CarouselInfo4;
import com.v1.video.domain.CommentEntity;
import com.v1.video.domain.LoginInfo;
import com.v1.video.domain.OptionInfo;
import com.v1.video.domain.PaikeVideoDetailEntity;
import com.v1.video.domain.PaikeVideoDetailPageInfo4;
import com.v1.video.domain.PaikeVideoDetailPageObj4;
import com.v1.video.domain.ResultInfoEntity;
import com.v1.video.domain.ScenarioVideoInfo;
import com.v1.video.domain.SetHead;
import com.v1.video.domain.VPaikeCommentInfo;
import com.v1.video.domain.VPaikeCommentListInfoEntity;
import com.v1.video.domain.VPaikeVideoInfo;
import com.v1.video.domain.VideoAdEntity;
import com.v1.video.domain.VideoCollectionInfoEntity;
import com.v1.video.domain.VideoDetailInfoNew4;
import com.v1.video.domain.VideoReportInfoEntity;
import com.v1.video.engine.NetEngine;
import com.v1.video.engine.RequestEngine;
import com.v1.video.httpApi.V1VideoHttpApi;
import com.v1.video.httpmanager.ParamList;
import com.v1.video.httpmanager.ParamList.Parameter;
import com.v1.video.httpmanager.RequestManager;
import com.v1.video.httpmanager.RequestManager.OnResponseListener;
import com.v1.video.interfaces.CommentDataCallBack;
import com.v1.video.util.DoubleClickUtil;
import com.v1.video.util.Helper;
import com.v1.video.util.Logger;
import com.v1.video.util.TransferUtils;
import com.v1.video.util.Utility;
import com.v1.video.util.Utils;
import com.v1.video.view.CircleFlowIndicator;
import com.v1.video.view.CommentEditFragment;
import com.v1.video.view.CustomShareSheetDialog;
import com.v1.video.view.CustomShareSheetDialog.OnShareSheetItemClick;
import com.v1.video.view.CustomVideoView;
import com.v1.video.view.CustomVideoView.SizeChangeLinstener;
import com.v1.video.view.ViewFlow;
import com.v1.video.widgets.MyDialog;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.Platform.ShareParams;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.sina.weibo.SinaWeibo;
import cn.sharesdk.tencent.qq.QQ;
import cn.sharesdk.tencent.qzone.QZone;

public class PaikeVideoDetailActivity2 extends BaseActivity implements
		OnClickListener {

	private final String TAG = "PaikeVideoDetailActivity";
	private LinearLayout layoutLl;
	private ListView aboutLv;

	private TextView txtPlayNum;
	private TextView descTv;

	public LinearLayout layattention;
	public ImageView ivAttention;

	private static final int OVERLAY_TIMEOUT = 3000;
	private static final int sLogTimeout = 5000; // 消息延迟时间
	private static final int FADE_OUT = 1;
	private static final int SHOW_PROGRESS = 2;
	private static final int SURFACE_SIZE = 3;
	private static final int FADE_OUT_INFO = 4;
	private static final int PAUSE = 5;
	private static final int STATE_FOCOUS_OF_USER = 6;
	private static final int SEND_LOG = 7;
	/** 获取评论 */
	private static final int STATE_GET_COMMENT = 0x0008;
	/** 广告 */
	private static final int STATE_GET_COURSE = 0x0009;
	/** 当前用户的头像 */
	private static final int STATE_GET_COMMENT_AUTHOR = 0x0010;
	/** 刷新评论数据 */
	private static final int STATE_REFRESH_COMMENT = 0x0011;
	/** 获取详情数据 */
	private static final int STATE_GET_VIDEODATA = 0x0012;
	/** 直接先播放 */
	private static final int STATE_GO_TO_PLAY = 0x0013;
	/** 查询收藏举报 */
	private static final int STATE_INIT_COLLECT_REPORT = 0x0014;
	private final int STATE_SET_WINDOW_NOTITLE = 0x0015;
	/** video标题栏 */
	private View mOverlayHeader;
	/** video底部操作栏 */
	private View mOverlay;
	private boolean overlayShowing = false;

	private VPaikeVideoInfo videoInfo;
	private ScenarioVideoInfo scenarioVideoInfo;
	private CustomVideoView vv_video;
	private SeekBar seekbar;
	boolean isStart = false;
	private LinearLayout waitingLl;
	private int screenHeight;
	private int screenWidth;
	private TextView timeTv;
	private TextView lengthTv;
	/** 是否自动播放 */
	private boolean isAutoPlay;
	/** 判断是否点击了播放按钮，设置不自动播放时可能引起问题 */
	private boolean clickPlay = false;
	private boolean isCanPlay = true; // 是否可以播放
	private boolean isFullBack = false;
	private boolean isPause = false;
	/** 是否有播放地址，若有，则先播放后读取数据 */
	private boolean isHasUrl = false;
	/** 判断是否跳转到评论页面，这个页面会引起视频的重新准备 */
	private boolean isGotoComment = false;
	private ImageView playVideo;
	// private View playIv;
	// private TextView loadRateView;
	private int loadRate = -1; // 当前加载百分比
	boolean isOnline;// 是否是网络地址

	private int position = 0; // 当前播放进度

	private Bitmap shareBitmap;
	private int duration = 0;
	private String mFlag;

	// private HorizontalListView1 galleryVidelAboutList = null;
	// private RelativeLayout layoutVideoAboutBacl = null;
	// private ViewFlow galleryVidelAboutList = null;
	private List<VideoDetailInfoNew4> listVideoAbout = new ArrayList<VideoDetailInfoNew4>();

	// private TextView txtTitle = null;//标题
	/** 是否本人的视频 */
	private boolean isOnSelf = false;
	/** 是否有专辑 */
	private boolean isHasAlbum = false;
	/** 专辑ID */
	private String albumId;
	// private TextView txtDuration = null;
	private TextView txtNumComment = null;
	private TextView txtCommentTip = null;
	private TextView txtCommentGame = null;
	// private AnimationDrawable mAnimationDrawable;
	private List<VPaikeCommentInfo> infos;
	private LinearLayout layoutComTipsBack = null;

	private RelativeLayout layoutVideoAdBack = null;
	private ImageView userImgComment = null;

	private LinearLayout layoutMoreBack = null;
	private boolean isMoreValue = false;

	

	private Handler handler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case FADE_OUT:
				hideOverlay(false);
				break;
			case SHOW_PROGRESS:
				// Logger.i(TAG, "handleMessage_SHOW_PROGRESS_本方法执行了");
				if (vv_video != null) {
					int currentPosition = vv_video.getCurrentPosition();
					if (position == currentPosition) {
						waitingLl.setVisibility(View.VISIBLE);
						playVideo.setVisibility(View.GONE);
					} else {
						waitingLl.setVisibility(View.GONE);
						// showOverlay();
						playVideo.setVisibility(View.VISIBLE);
					}
					if (currentPosition != 0)
						position = currentPosition;
					Logger.i("position", "currentPosition=" + currentPosition
							+ ",播放进度=" + position + "_duration=" + duration
							+ ",,百分比=" + (float) position / (float) duration);

					// 更新播放进度
					if (currentPosition == 0) {
						if (position != 0) {
							seekbar.setProgress(position);
						} else {
							seekbar.setProgress(0);
						}
					} else {
						seekbar.setProgress(position);
					}

					if (isOnline) {

						int j = vv_video.getBufferPercentage();
						// Logger.i("position", "缓冲进度="+j);

						int secondaryProgress = (j * seekbar.getMax() / 100);
						// 更新缓冲了多少，通常播放网络资源时候用到
						seekbar.setSecondaryProgress(secondaryProgress);
					} else {
						// 这里我们不需要第2进度，所以为0
						seekbar.setSecondaryProgress(0);
					}

					timeTv.setText(Utils.millisToString(position));

					sendEmptyMessageDelayed(SHOW_PROGRESS, 500);
				}
				break;
			case STATE_FOCOUS_OF_USER:
				// new GetUserFocous(scenarioVideoInfo.getVideoId()).execute();
				break;
			case STATE_GET_COMMENT:// 评论
//				getTheVideoComment(scenarioVideoInfo.getVideoId(), curPage);
				if (videoInfo != null) {
					mCurIndex = 0;
					mLastId = "0";
					getCommentData(videoInfo.getVideoId());
				}
				break;
			case STATE_GET_COURSE:// 广告
				getVideoAd();
				break;
			case STATE_GET_COMMENT_AUTHOR:
				if (LoginInfo.getInstance().isLogin()) {
					SetHead setHead = new SetHead();
					setHead.setHead(LoginInfo.getInstance().getUserImg(),
							LoginInfo.getInstance().getSex(), userImgComment);
				}

				break;
			case STATE_GET_VIDEODATA:
				getVideoDetail(scenarioVideoInfo.getVideoId());
				break;
			case STATE_GO_TO_PLAY:
				setVideoAbout();
				break;
			case STATE_INIT_COLLECT_REPORT:
				Logger.i(TAG, "下面将执行查询视频是否收藏");
				initVideoCollectAndReport(LoginInfo.getInstance().getUserId(),
						scenarioVideoInfo.getVideoId());
				break;
			case STATE_SET_WINDOW_NOTITLE:

				break;
			case SEND_LOG:
				if (vv_video != null) {
					videoPlayUpToServer("1", vv_video.getCurrentPosition()
							/ 1000 + "");
					msg = obtainMessage(SEND_LOG);
					sendMessageDelayed(msg, sLogTimeout);
				}
				break;
			}
		};
	};

	// private TextView commentTv;
	// private TextView videoTitleTv; // 播放器视频标题
	private RelativeLayout videoViewRl;// 播放器控件

	private LinearLayout bottomLl;
	// private boolean isAttentioned; //是否关注
	// private boolean isPraised = false; // 是否已赞
	private Boolean isCollect = false; // 是否收藏
	private Boolean isReport = false; // 是否举报
	private DoubleClickUtil doubleClick;

	private LinearLayout moreLl;
	private LinearLayout shareLl;

	/* 拍摄时相关视频id */
	private String relatedVideoId;

	// 锁屏广播
	private LockScreenReceiver lockScreenReceiver;
	// 解锁屏幕广播
	private UnlockScreenReceiver unlockScreenReceiver;
	private boolean unlockflag = false;

	// 评论相关
	private PullToRefreshListView commentPlv;
	private ListView comment;
	// private ListViewForScrollView comment;
	private List<VPaikeCommentInfo> commentVo;
	private CommentAdapter commentAdapter;
	private PopupWindow popupWindow;
	// private String videoId;
	private int curPage = 0;
	View headView = null;
	private RelativeLayout layoutCommentTitleBack = null;
	private LinearLayout layoutAboutVideoBack = null;
	private RelativeLayout layoutCommentWriteTipsBack = null;


	public static final int FROM_ACTIVITY = 1;// 从活动点进来
	public static final int FROM_ATTENTION = 2;// 从下主横条的关注进来，要做评论
	public static String fromActivity = "fromActivity";// 来自活动
	/** 0未有，1：来自; 2来自关注视频列表要做评论用 */
	private int from = 0;

	// 广告
	private AdImageAdapter mAdapter;
	private ViewFlow mAdvFlow;
	private CircleFlowIndicator mViewflowindic;
	private RelativeLayout layoutAdvTxtback = null;
	private int mIndexAdv = -1;
	ArrayList<CarouselInfo4> listCourseInfo;
	// 广告
	private ImageView btnMore = null;

	private EditText editComment;
	// private TextView btnSend;

	private IWXAPI api;

	private final int STATE_RETURN_LOGIN_REWARD = 0x1001;// 赞赏返回后直接去打赏确认页

	private RelativeLayout layout_overback = null;
	private RelativeLayout layout_zanBack = null;
	private LinearLayout layoutUserInfoBack = null;
	private View viewUser1 = null;
	private View viewUser2 = null;
	private View viewUser3 = null;
	private View viewAdv1 = null;
	private View viewAdv2 = null;
	private View viewAdv3 = null;
	private View line_8 = null;
	private View line_9 = null;
	private View line_10 = null;
	private View line_11 = null;
	private View line_12 = null;
	private String mSource = Constant.ADV_SOURCE_OTHER;
	private String mUuid;
	private TextView mTvSendcomment;
	private ImageView mIvCollection;
	private CommentEditFragment mCommentEditFragment;
	private String mCommentId;
	private String mReplyName;
	private String mLastId = "0";
	private int mCurIndex = 0;
	private View mLayComment;
	

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		outState.putInt("position", position);
		outState.putSerializable("scenarioVideoInfo", scenarioVideoInfo);
		outState.putSerializable("videoInfo", videoInfo);
	}

	@Override
	protected void onRestoreInstanceState(Bundle savedInstanceState) {
		super.onRestoreInstanceState(savedInstanceState);
		if (savedInstanceState != null) {
			position = savedInstanceState.getInt("position");
			scenarioVideoInfo = (ScenarioVideoInfo) savedInstanceState
					.getSerializable("scenarioVideoInfo");
			videoInfo = (VPaikeVideoInfo) savedInstanceState
					.getSerializable("videoInfo");
		}
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 
		ShareSDK.initSDK(this);
		MobclickAgent.onEvent(this, "photographerVideoDetail_id");
		// setContentView(R.layout.activity_paike_video_detail);
		// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
		setContentView(R.layout.item_paike_detail_listview1);
	}

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		// super.onBackPressed();
		if(new_toast != null){
			new_toast.cancel();
		}
		back();
	}

	private void back() {
		Logger.i(TAG, "getResources().getConfiguration().orientation=="
				+ getResources().getConfiguration().orientation);
		if (getResources().getConfiguration().orientation == 1) {
			finish();
		} else {
			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		}
	}

	protected void enableDClickReturn() {
		doubleClick = new DoubleClickUtil(
				new DoubleClickUtil.OnDoubleClickListener() {
					@Override
					public void onDoubleClick() {
						finish();
					}
				});
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#finish()
	 */
	@Override
	public void finish() {
		// TODO Auto-generated method stub
		if (!TextUtils.isEmpty(mFlag) && mFlag.equals("1")) {
			// 处理从打赏成功查看视频跳转主页
			Intent intent = new Intent();
			intent.setClass(this, MainPageNewActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
			startActivity(intent);
			return;
		}
		if (Utils.mainPageActivity == null) {
			Intent open = new Intent();
			open.setComponent(new ComponentName("com.v1.video",
					"com.v1.video.activity.SplashActivity"));
			this.startActivity(open);
		} else {
			if (from == FROM_ATTENTION) {
				Intent intent = new Intent();
				intent.putExtra("commentNum", "" + commentVo.size());
				setResult(RESULT_OK, intent);
			}
		}
		if (isHasUrl) {
			Intent intent = new Intent();
			intent.putExtra("position", position);
			setResult(RESULT_OK, intent);
		}
		super.finish();
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent event) {

		if (doubleClick != null) {
			doubleClick.dispatchTouchEvent(event);
		}
		return super.dispatchTouchEvent(event);
	}

	@Override
	protected void initView() {
		// txtTitle = (TextView) findViewById(R.id.tv_title);
		headView = getLayoutInflater().inflate(
				R.layout.activity_paike_video_detail2, null);
		layoutLl = (LinearLayout) headView.findViewById(R.id.ll_content);
		layoutLl.setVisibility(View.GONE);
		aboutLv = (ListView) headView.findViewById(R.id.lv_about_video_list);
		ivAttention = (ImageView) headView.findViewById(R.id.iv_attention);
//		layattention = (LinearLayout) headView.findViewById(R.id.lay_attention);
//		tvAttention = (TextView) headView.findViewById(R.id.tv_attention);
		// addressTv = (TextView) headView.findViewById(R.id.tv_address);
		// addressTv = (TextView) headView
		// .findViewById(R.id.paike_detail_video_position);

		// createTimeTv = (TextView) headView.findViewById(R.id.tv_time);
		txtPlayNum = (TextView) headView.findViewById(R.id.tv_play_count);
		descTv = (TextView) headView.findViewById(R.id.tv_description);
		tv_source = (TextView) headView.findViewById(R.id.tv_source);

		vv_video = (CustomVideoView) findViewById(R.id.vv);
		seekbar = (SeekBar) findViewById(R.id.sb);
		waitingLl = (LinearLayout) findViewById(R.id.waiting_ll);
		// loadRateView = (TextView) findViewById(R.id.load_rate);
		lengthTv = (TextView) findViewById(R.id.tv_end_time);
		timeTv = (TextView) findViewById(R.id.tv_begin_time);
		// playVideo = (ImageView) headView.findViewById(R.id.iv_video_play);
		playVideo = (ImageView) findViewById(R.id.iv_play);
		// playIv = headView.findViewById(R.id.iv_play);

		bottomLl = (LinearLayout) findViewById(R.id.ll_bottom);

		// videoTitleTv = (TextView) headView
		// .findViewById(R.id.player_overlay_title);

		mOverlayHeader = (RelativeLayout) headView
				.findViewById(R.id.player_overlay_header);
		mOverlay = (RelativeLayout)findViewById(R.id.player_overlay);

		videoViewRl = (RelativeLayout) findViewById(R.id.rl_video_view);
		videoViewRl.setVisibility(View.GONE);

		layoutCommentTitleBack = (RelativeLayout) headView
				.findViewById(R.id.paike_dtail_comment_back);
		layoutAboutVideoBack = (LinearLayout) headView
				.findViewById(R.id.paike_detail_videoabout_back);
//
//		layoutUserInfoBack = (LinearLayout) headView
//				.findViewById(R.id.paikedetail_person_info_back);
		viewUser1 = (View) headView.findViewById(R.id.paikedetail_line_1);
//		viewUser2 = (View) headView.findViewById(R.id.paikedetail_line_2);
		viewUser3 = (View) headView.findViewById(R.id.paikedetail_line_3);
		viewAdv1 = (View) headView.findViewById(R.id.paikedetail_line_4);
		viewAdv2 = (View) headView.findViewById(R.id.paikedetail_line_5);
		viewAdv3 = (View) headView.findViewById(R.id.paikedetail_line_6);
		layout_zanBack = (RelativeLayout) headView
				.findViewById(R.id.paike_detail_zan_back);
		line_8 = (View) headView.findViewById(R.id.paikedetail_line_8);
		line_9 = (View) headView.findViewById(R.id.paikedetail_line_9);
		line_10 = (View) headView.findViewById(R.id.paikedetail_line_10);
		line_11 = (View) headView.findViewById(R.id.paikedetail_line_11);
		line_12 = (View) headView.findViewById(R.id.paikedetail_line_12);
		layoutCommentWriteTipsBack = (RelativeLayout) headView
				.findViewById(R.id.paikedetail_write_comment_tips_back);


		commentPlv = (PullToRefreshListView) findViewById(R.id.paike_detail_listview);
		// comment = (ListView) findViewById(R.id.paike_detail_listview);
		comment = commentPlv.getRefreshableView();
		commentPlv.setMode(Mode.DISABLED);
		comment.addHeaderView(headView);

		// editComment = (EditText)findViewById(R.id.paike_detail_comm_content);
		editComment = (EditText) headView
				.findViewById(R.id.paike_detail_comm_edit);
		// btnSend = (TextView)findViewById(R.id.paike_detail_comm_send);

		// 广告
		mAdvFlow = (ViewFlow) headView.findViewById(R.id.advFlow);
		mAdvFlow.setViewGroup(commentPlv.getRefreshableView());
		mViewflowindic = (CircleFlowIndicator) headView
				.findViewById(R.id.viewflowindic);
		layoutAdvTxtback = (RelativeLayout) headView
				.findViewById(R.id.advtxt_lay_back);
		// 广告
		// 相关视频
		btnMore = (ImageView)findViewById(R.id.iv_set);
		layoutVideoAdBack = (RelativeLayout) headView
				.findViewById(R.id.paike_video_detail_ad_back);
		txtNumComment = (TextView) findViewById(R.id.paike_detail_comment_title_num);
		txtCommentTip = (TextView) findViewById(R.id.paike_detail_comment_title);
		txtCommentGame = (TextView) findViewById(R.id.paike_detail_comment_right);
		layoutComTipsBack = (LinearLayout) headView
				.findViewById(R.id.paike_detail_comm_tips);

		userImgComment = (ImageView) headView
				.findViewById(R.id.comment_headview_head_icon);
		layout_overback = (RelativeLayout)findViewById(R.id.player_overlay_back);

		layoutMoreBack = (LinearLayout)findViewById(R.id.paike_detail_more_back);
		
		mTvSendcomment = (TextView) findViewById(R.id.tv_sendcomment);
		mIvCollection = (ImageView) findViewById(R.id.iv_collection);
		mLayComment = findViewById(R.id.lay_comment);
	}

	@Override
	protected void initData() {
		// txtTitle.setText(R.string.video_paike_detail_title);
		editComment.setFilters(Utility.GetEmojiFilter());
		Utility.AddTextWatcher(editComment);
		btnMore.setVisibility(View.VISIBLE);
		btnMore.setImageResource(R.drawable.btn_more_selector1);
		Intent fromIntent = getIntent();
		source_name = fromIntent.getStringExtra("name");
		if(!TextUtils.isEmpty(source_name)){
			tv_source.setText("视频来源："+source_name);
		}else{
			tv_source.setText("");
		}
		
		from = fromIntent.getIntExtra(fromActivity, 0);

		Display display = getWindowManager().getDefaultDisplay();
		screenHeight = display.getHeight();
		screenWidth = display.getWidth();
		// 设置播放器的大小
		// LayoutParams layoutParams = videoViewRl.getLayoutParams();
		// layoutParams.height = screenWidth;
		// layoutParams.width = screenWidth;
		// videoViewRl.setLayoutParams(layoutParams);
		setVideoDefauleScale();
		OptionInfo optionInfo = OptionInfo
				.getInstance(PaikeVideoDetailActivity2.this);
		// 是否自动播放
		// isAutoPlay = optionInfo.isVideoDetailPageAutoPlay();
		isAutoPlay = Utils.isCanPlay(PaikeVideoDetailActivity2.this);
		if (isAutoPlay) {
			isPause = false;
		} else {
			isPause = true;
		}
		if (isFullBack) {
			isAutoPlay = false;
		}
		if (from == FROM_ATTENTION) {// 需要直接评论
			gotoComment();
		}
		// 是否双击关闭
		// if (optionInfo.isDoubleClickClose()) {
		// enableDClickReturn();
		// }
		Intent intent = getIntent();
		mFlag = intent.getStringExtra("Flag");
		Serializable serializableExtra = intent
				.getSerializableExtra("videoInfo");
		mSource = intent.getStringExtra("source");
		if (serializableExtra != null) {
			scenarioVideoInfo = (ScenarioVideoInfo) serializableExtra;
		}
		Logger.i(TAG, "videoId==" + scenarioVideoInfo.getVideoId());
		mUuid = UUID.randomUUID().toString();
		position = intent.getIntExtra("position", 0);
		if (scenarioVideoInfo.getVideoUrl() != null
				&& scenarioVideoInfo.getVideoUrl().length() > 5) {
			isHasUrl = true;
			Logger.i(TAG, "videoUrl==" + scenarioVideoInfo.getVideoUrl());
			Message msg = handler.obtainMessage();
			msg.what = STATE_GO_TO_PLAY;
			handler.sendMessage(msg);
			// setVideoAbout();
			layoutLl.setVisibility(View.VISIBLE);
//			layoutUserInfoBack.setVisibility(View.GONE);
			layoutVideoAdBack.setVisibility(View.GONE);
			layout_zanBack.setVisibility(View.GONE);
//			viewUser2.setVisibility(View.GONE);
			viewUser3.setVisibility(View.GONE);
			viewAdv2.setVisibility(View.GONE);
			viewAdv3.setVisibility(View.GONE);
			layoutAboutVideoBack.setVisibility(View.GONE);
		} else {
			getVideoDetail(scenarioVideoInfo.getVideoId());
		}
		if (LoginInfo.getInstance().isLogin()) {
			// new GetVideoDetailAsync(scenarioVideoInfo.getVideoId(), LoginInfo
			// .getInstance().getUserId()).execute();//ft_11.25替换为上面一行

			// new GetDataAsync(scenarioVideoInfo.getVideoId()).execute();
			Message msg = handler.obtainMessage();
			msg.what = STATE_INIT_COLLECT_REPORT;
			handler.sendMessageAtTime(msg, 1000);
			// initVideoCollectAndReport(LoginInfo.getInstance().getUserId(),
			// scenarioVideoInfo.getVideoId());
		} else {
			// new GetVideoDetailAsync(scenarioVideoInfo.getVideoId(), null)
			// .execute();
		}

		// 锁屏时
		IntentFilter lockScreenFilter = new IntentFilter();
		lockScreenFilter.addAction(Intent.ACTION_SCREEN_OFF);
		lockScreenReceiver = new LockScreenReceiver();
		registerReceiver(lockScreenReceiver, lockScreenFilter);
		// 锁屏解锁时
		IntentFilter unlockScreenFiler = new IntentFilter();
		unlockScreenFiler.addAction(Intent.ACTION_SCREEN_ON);
		unlockScreenReceiver = new UnlockScreenReceiver();
		registerReceiver(unlockScreenReceiver, unlockScreenFiler);

		commentVo = new ArrayList<VPaikeCommentInfo>();
		commentAdapter = new CommentAdapter(this,CommentAdapter.VIDEO_FLAG);
		commentAdapter.setNoComment(false);
		// comment = commentPlv.getRefreshableView();
		// comment.setChoiceMode(Mode.PULL_FROM_END);
		comment.setAdapter(commentAdapter);
		// new GetHeaderDataTask(false).execute();
		// getTheVideoComment(scenarioVideoInfo.getVideoId(), curPage);

		api = WXAPIFactory.createWXAPI(this, Constant.APP_ID);
		api.registerApp(Constant.APP_ID);

		// ActivityManager.getMemoryClass()

	}

	private void setVideoAbout() {
		setVideoPath(scenarioVideoInfo.getVideoUrl());
		if (isAutoPlay && isCanPlay) {
			Logger.i(TAG, "下面执行videoStart");
			// videoStart();
			// updateVideoPalyerUI(true);
		}
		seekbar.setProgress(0);
		seekbar.setMax(0);
		videoViewRl.setVisibility(View.VISIBLE);
		waitingLl.setVisibility(View.VISIBLE);
		// Message message = Message.obtain();
		// message.what = STATE_GET_VIDEODATA;
		// // handler.sendMessage(message);
		// handler.sendMessageAtTime(message, 2500);
	}

	private void gotoComment() {
//		isCanPlay = false;
//		isAutoPlay = false;
		editComment.setFocusable(true);
		editComment.requestFocus();
		InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		// imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
		imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
	}

	// 展现广告区
	private void showAdv() {
		int perWidth = (int) this.getResources().getDimension(
				R.dimen.cf_indicator_per_width);
		int width = listCourseInfo.size() * perWidth;
		ViewGroup.LayoutParams params= mViewflowindic.getLayoutParams();
		params.width = width;
		mViewflowindic.setLayoutParams(params);
		mAdapter = new AdImageAdapter(PaikeVideoDetailActivity2.this,
				listCourseInfo);
		mAdvFlow.setAdapter(mAdapter);
		mAdvFlow.setmSideBuffer(listCourseInfo.size());
		mAdvFlow.setFlowIndicator(mViewflowindic);
		if (listCourseInfo.size() <= 1) {
			mViewflowindic.setVisibility(View.GONE);
			layoutAdvTxtback.setVisibility(View.GONE);
		} else {
			mAdvFlow.setSelection(listCourseInfo.size() * 1000); // 设置初始位置
		}
		int type = Integer.parseInt(listCourseInfo.get(0).getType()) + 1;
		if (type == CarouselInfo4.TYPE_ADV) {
			RequestEngine request = new RequestEngine();
			request.sendADVLogToServer(PaikeVideoDetailActivity2.this,
					Constant.STATE_ADV_CZBM_2 + "", Constant.STATE_ADV_CZSX_4
							+ "_" + listCourseInfo.get(0).getId(), ""
							+ Constant.STATE_ADV_CZJG_1);
			if (listCourseInfo.get(0).getAdShow() != null
					&& listCourseInfo.get(0).getAdShow().length() > 5) {
				RequestEngine request1 = new RequestEngine();
				request1.askThirdADVLink(PaikeVideoDetailActivity2.this,
						listCourseInfo.get(0).getAdShow());
			}
			new NetEngine().AdUpToServer(PaikeVideoDetailActivity2.this,
					listCourseInfo.get(mIndexAdv).getAdid(), LoginInfo
							.getInstance().getUserId(), "7", "1", "-1");
		}
		// 自动播放
		// mAdvFlow.setTimeSpan(10000);
		// mAdvFlow.setSelection(3 * 1000); // 设置初始位置
		// mAdvFlow.startAutoFlowTimer(); // 启动自动播放
	}

	/**
	 * 查询是否收藏，是否举报
	 * 
	 * @param userId
	 * @param videoId
	 */
	private void initVideoCollectAndReport(String userId, String videoId) {
		quertVideoCollect(userId, videoId);
		quertVideoReport(userId, videoId);
	}

	@Override
	protected void setListener() {
		findViewById(R.id.iv_share).setOnClickListener(this);
		// 底部导航按钮
		findViewById(R.id.iv_result).setOnClickListener(this);

		// moreTv.setOnClickListener(this);

		findViewById(R.id.iv_video_reverse).setOnClickListener(this);
		playVideo.setOnClickListener(this);
		findViewById(R.id.ll_result).setOnClickListener(this);
		// playIv.setOnClickListener(this);


		setListenerForVideoview();
		// findViewById(R.id.ll_add_self_video).setOnClickListener(this);

		// 更多
		// findViewById(R.id.ll_collect).setOnClickListener(this);
		// findViewById(R.id.ll_report).setOnClickListener(this);
		// 分享
		// findViewById(R.id.ll_weichalt).setOnClickListener(this);
		// findViewById(R.id.ll_pyq).setOnClickListener(this);
		btnMore.setOnClickListener(this);
		// adIv.setOnClickListener(this);
		// findViewById(R.id.iv_close_ad).setOnClickListener(this);

		// findViewById(R.id.paikedetail_shang_back).setOnClickListener(this);//ft_1.15需修改暂时注释

		// btnSend.setOnClickListener(this);
		commentPlv.setOnRefreshListener(new OnRefreshListener2<ListView>() {
			@Override
			public void onPullDownToRefresh(
					PullToRefreshBase<ListView> refreshView) {
				String label = DateUtils.formatDateTime(
						PaikeVideoDetailActivity2.this,
						System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME
								| DateUtils.FORMAT_SHOW_DATE
								| DateUtils.FORMAT_ABBREV_ALL);
				refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);
				curPage = 0;
				// new GetHeaderDataTask(true).execute();
//				getTheVideoComment(scenarioVideoInfo.getVideoId(), curPage);
				if (videoInfo != null) {
					mCurIndex = 0;
					mLastId = "0";
					getCommentData(videoInfo.getVideoId());
				}
			}

			@Override
			public void onPullUpToRefresh(
					PullToRefreshBase<ListView> refreshView) {
				Logger.i(TAG, "onPullUpToRefresh执行了11111");
				curPage++;
//				getTheVideoComment(scenarioVideoInfo.getVideoId(), curPage);
				// new GetFooterDataTask().execute();
				getCommentData(videoInfo.getVideoId());
			}

		});

		AppContext application = (AppContext) getApplication();
		final String urlGame = application.getUrlH5Game();
		Logger.i(TAG, "urlGame==" + urlGame);
		if (urlGame != null && urlGame.length() >= 5) {
			txtCommentGame.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					// startActivityHelper(new
					// Intent(PaikeVideoDetailActivity.this,
					// WebViewActivity2.class).putExtra("adLink",urlGame));
					startActivityHelper(new Intent(
							PaikeVideoDetailActivity2.this,
							WebViewActivity3.class).putExtra("adLink", urlGame)
							.putExtra("type", WebViewActivity3.STATE_TYPE_1));
				}
			});
		}

		editComment.setOnKeyListener(new OnKeyListener() {

			@Override
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				// TODO Auto-generated method stub
				if (keyCode == KeyEvent.KEYCODE_ENTER
						&& event.getAction() == KeyEvent.ACTION_DOWN) {
					Logger.i(TAG, "发送评论1111111111");
					if (LoginInfo.getInstance().isLogin()) {
						gotoSendComment();
					} else {
						startActivity(new Intent(v.getContext(),
								SettingLoginActivity.class).putExtra(
								"loginFlag", 2));
					}
				}
				return false;
			}
		});

		findViewById(R.id.ll_collect).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						layoutMoreBack.setVisibility(View.GONE);
						isMoreValue = false;
						if (isCollect) {
							// 已经收藏
							// new
							// DeletCollectionVideoAsync(LoginInfo.getInstance()
							// .getUserId(), videoInfo.getVideoId()).execute();
							getCancellCollectionTheVideo(videoInfo.getVideoId());
						} else {
							// 还未收藏
							// new
							// CollectionVideoAsync(LoginInfo.getInstance().getUserId(),
							// videoInfo.getVideoId()).execute();
							getCollectionTheVideo(videoInfo.getVideoId());
						}
					}
				});
		findViewById(R.id.ll_report).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						layoutMoreBack.setVisibility(View.GONE);
						isMoreValue = false;
						if (!isReport) {
							// new
							// AddVideoReportAsync(LoginInfo.getInstance().getUserId(),
							// videoInfo.getVideoId()).execute();
							getReportTheVideo(videoInfo.getVideoId());
						} else {
							new_toast = Utils.showtoast(PaikeVideoDetailActivity2.this,
									"已经\n举报", 0);
						}
					}
				});
		findViewById(R.id.ll_dashang).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						layoutMoreBack.setVisibility(View.GONE);
						isMoreValue = false;
						videoPause();
						showRewardDialog();
					}
				});
		findViewById(R.id.tv_cancel).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						layoutMoreBack.setVisibility(View.GONE);
						isMoreValue = false;
					}
				});
		
		mTvSendcomment.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				showSendCommentDialog("", "");
			}
		});
		
		mIvCollection.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(LoginInfo.getInstance().isLogin()){
					layoutMoreBack.setVisibility(View.GONE);
					isMoreValue = false;
					if (isCollect) {
						// 已经收藏
						getCancellCollectionTheVideo(videoInfo.getVideoId());
					} else {
						// 还未收藏
						getCollectionTheVideo(videoInfo.getVideoId());
					}
				} else {
					transferLogin(0);
				}
			}
		});
		
		mAdvFlow.setOnScrollListener(new OnScrollListener() {

			@Override
			public void onScrollStateChanged(AbsListView view, int scrollState) {
				Logger.i(TAG, "mAdvFlow.onScrollStateChanged");
				// TODO Auto-generated method stub
				int pos = mAdvFlow.getSelectedItemPosition();

				mIndexAdv = pos % listCourseInfo.size();
				if (mIndexAdv >= listCourseInfo.size()) {
					mIndexAdv = 0;
				}
				if (mIndexAdv < 0) {
					return;
				}
				Logger.i(TAG, "11mIndexAdv==" + mIndexAdv);
				int type = Integer.parseInt(listCourseInfo.get(mIndexAdv)
						.getType()) + 1;
				Logger.i(TAG, "11mIndexAdv_type=" + type);
				if (type == CarouselInfo4.TYPE_ADV) {
					RequestEngine request = new RequestEngine();
					request.sendADVLogToServer(PaikeVideoDetailActivity2.this,
							Constant.STATE_ADV_CZBM_2 + "",
							Constant.STATE_ADV_CZSX_4 + "_"
									+ listCourseInfo.get(mIndexAdv).getId(), ""
									+ Constant.STATE_ADV_CZJG_1);
					if (listCourseInfo.get(mIndexAdv).getAdShow() != null
							&& listCourseInfo.get(mIndexAdv).getAdShow()
									.length() > 5) {
						RequestEngine request1 = new RequestEngine();
						request1.askThirdADVLink(PaikeVideoDetailActivity2.this,
								listCourseInfo.get(mIndexAdv).getAdShow());
					}
					new NetEngine().AdUpToServer(PaikeVideoDetailActivity2.this,
							listCourseInfo.get(mIndexAdv).getAdid(), LoginInfo
									.getInstance().getUserId(), "7", "1", "-1");
				}
			}

			@Override
			public void onScroll(AbsListView view, int firstVisibleItem,
					int visibleItemCount, int totalItemCount) {
				// TODO Auto-generated method stub
				Logger.i(TAG, "mAdvFlow_onScroll");
			}
		});
	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {
		case R.id.iv_user_img:
			if (LoginInfo.getInstance().isLogin()) {
				if (videoInfo != null
						&& !videoInfo.getUserId().equals(
								LoginInfo.getInstance().getUserId())) {
					gotoOtherPersonHome(videoInfo.getUserId(),
							videoInfo.getUserName(), videoInfo.getSex(), "0",
							videoInfo.getUserImg(), videoInfo.getUserDesc(),
							"0");
				}
			} else {
				// startActivityForResult(new Intent(v.getContext(),
				// OtherHomeActivity.class).putExtra("userId",
				// videoInfo.getUserId()),
				// Constant.REQUESTCODE_OTHERPERSON_CODE);
				gotoOtherPersonHome(videoInfo.getUserId(),
						videoInfo.getUserName(), videoInfo.getSex(), "0",
						videoInfo.getUserImg(), videoInfo.getUserDesc(), "0");
			}
			break;
		// case R.id.ll_add_self_video:
		// if (videoInfo != null) {
		// // startActivity(new
		// // Intent(v.getContext(),RecorderActivity.class));
		// Intent intent = XiaoyingUtils.initCaptureVideoIntent(v
		// .getContext());
		// if (intent != null) {
		// PicUtils.clearImgCache();
		// relatedVideoId = videoInfo.getVideoId();
		// MobclickAgent.onEvent(v.getContext(), "addVideo_id");
		// startActivityForResult(intent,
		// Constant.REQUEST_CODE_VIDEO_CAPTURE);
		// }
		// }
		// break;
		case R.id.iv_video_reverse:// 翻转
			hideOverlay(false);
			if (getResources().getConfiguration().orientation == 1) {
				setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
			} else {
				setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
			}
			// if (videoInfo != null) {
			// Intent intent = new Intent(PaikeVideoDetailActivity.this,
			// VideoPlayerActivity.class);
			// ArrayList<VideoBaseInfo> list = new ArrayList<VideoBaseInfo>();
			// list.add(new VideoBaseInfo(videoInfo.getTitle(), videoInfo
			// .getVideoUrl()));
			// intent.putExtra("videoList", list);
			// intent.putExtra("position", vv_video.getCurrentPosition());
			// intent.putExtra("isPause", isPause);
			// if (vv_video != null) {
			// intent.putExtra("videoDuration", vv_video.getDuration());
			// } else {
			// intent.putExtra("videoDuration", 0);
			// }
			// startActivityForResult(intent, Constant.REQUESTCODE_FULL_SCREEN);
			// }
			break;
		case R.id.iv_play:
			updatePausePlay();
			break;
		case R.id.iv_share:
		case R.id.paikedetail_share_back:
		case R.id.bt_share:
			if (videoInfo != null) {
				Logger.i(TAG, "点击分享了。。。。");
				if (shareLl != null && shareLl.isShown()) {
					// closeShareLl();
				} else {
					closeMoreLl();
					if (videoInfo != null) {
						String url = Constant.PAIKE_VIDEO_SHARE_URL
								+ videoInfo.getImgUrl() + "&videoURL="
								+ videoInfo.getVideoUrl();
						if (videoInfo.getWabSiteUrl() != null
								&& videoInfo.getWabSiteUrl().length() > 5) {
							url = videoInfo.getWabSiteUrl();
						}
						String content = "\""
								+ videoInfo.getTitle()
								+ "\""
								+ "点此播放"
								+ "\""
								+ url
								+ "\""
								+ "（通过＃第一视频＃分享，@第一视频，聚合全球海量有趣有料有用的精选短视频，助你大开眼界！下载猛戳http://apps.v1.cn）";
						// strShareTitle = videoInfo.getTitle();
						strShareTitle = content;
					}
					showShareLl();

				}
			}
			break;
		case R.id.lay_result:
		case R.id.iv_result:
		case R.id.ll_result:
			back();
			break;
		case R.id.bt_comment:
			if (LoginInfo.getInstance().isLogin()) {
				if (videoInfo != null) {
					isGotoComment = true;
					gotoComment();
				}

			} else {
				startActivity(new Intent(v.getContext(),
						SettingLoginActivity.class).putExtra("loginFlag", 2));
			}

			break;
		case R.id.paikedetail_praise_back:// 赞
		case R.id.iv_set:// 右上角的更多
			if (videoInfo != null) {
				if (moreLl != null && moreLl.isShown()) {
					closeMoreLl();
				} else {
					if (LoginInfo.getInstance().isLogin()) {
						showMoreLl();
					} else {
						startActivityForResult(new Intent(v.getContext(),
								SettingLoginActivity.class).putExtra(
								"loginFlag", 2),
								Constant.REQUESTCODE_LOGIN_CODE);
					}
				}
			}
			break;
		case R.id.bt_more:
			if (videoInfo != null) {
				if (moreLl != null && moreLl.isShown()) {
					closeMoreLl();
				} else {
					if (LoginInfo.getInstance().isLogin()) {
						if (isCollect != null && isReport != null) {
							showMoreLl();
						} else {
							initVideoCollectAndReport(LoginInfo.getInstance()
									.getUserId(), videoInfo.getVideoId());
						}
					} else {
						startActivityForResult(new Intent(v.getContext(),
								SettingLoginActivity.class).putExtra(
								"loginFlag", 2),
								Constant.REQUESTCODE_LOGIN_CODE);
					}
				}
			}
			break;

		// case R.id.ll_collect:// 收藏
		// if (isCollect) {
		// // 已经收藏
		// // new DeletCollectionVideoAsync(LoginInfo.getInstance()
		// // .getUserId(), videoInfo.getVideoId()).execute();
		// getCancellCollectionTheVideo(videoInfo.getVideoId());
		// } else {
		// // 还未收藏
		// // new CollectionVideoAsync(LoginInfo.getInstance().getUserId(),
		// // videoInfo.getVideoId()).execute();
		// getCollectionTheVideo(videoInfo.getVideoId());
		// }
		// break;
		// case R.id.ll_report:// 举报
		// if (!isReport) {
		// // new AddVideoReportAsync(LoginInfo.getInstance().getUserId(),
		// // videoInfo.getVideoId()).execute();
		// getReportTheVideo(videoInfo.getVideoId());
		// } else {
		// Utils.showToast(PaikeVideoDetailActivity.this, "已经\n举报", 0);
		// }
		// break;

		// case R.id.ll_weichalt:// 微信
		// onkeyshare(v, ShareSDK.getPlatform(PaikeVideoDetailActivity.this,
		// Wechat.NAME));
		// closeShareLl();
		// break;
		// case R.id.ll_pyq:// 朋友圈
		// onkeyshare(v, ShareSDK.getPlatform(PaikeVideoDetailActivity.this,
		// WechatMoments.NAME));
		// closeShareLl();
		// break;
		// case R.id.paike_detail_comm_send://直接发送评论
		// gotoSendComment();
		// break;

		// case R.id.iv_ad:// 广告
		// startActivity(new Intent(PaikeVideoDetailActivity.this,
		// WebViewActivity.class).putExtra("adLink", adLink));
		// adRl.setVisibility(View.GONE);
		// break;
		// case R.id.iv_close_ad:// 广告 关闭
		// adRl.setVisibility(View.GONE);
		// break;
		}

	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		// TODO Auto-generated method stub
		super.onConfigurationChanged(newConfig);
		// Display display = getWindowManager().getDefaultDisplay();
		// screenHeight = display.getHeight();
		// screenWidth = display.getWidth();
		if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
			setVideoDefauleScaleLandScape();
			setUiFullScreen();
		} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
			setVideoDefauleScale();
			setUiScreenWithTitle();
		}

		Message msg = handler.obtainMessage();
		msg.what = STATE_SET_WINDOW_NOTITLE;
		handler.sendMessageAtTime(msg, 500);
	}

	private void gotoSendComment() {
		String content = editComment.getText().toString().trim();
		// if(LoginInfo.getInstance().isLogin()){

		if (!TextUtils.isEmpty(content)) {
			// new
			// SendCommentTaskForPaike(content,LoginInfo.getInstance().getUserId()).execute();
			if (videoInfo != null) {
				getWriteCommentOfTheVideo(videoInfo.getVideoId(), content);
			} else {
				hideSoftInput();
			}
		} else {
			ToastAlone.showToast(PaikeVideoDetailActivity2.this,
					R.string.comment_not_null, 1);
		}
		// }else{
		// startActivityForResult(new Intent(PaikeVideoDetailActivity.this,
		// SettingLoginActivity.class).putExtra(
		// "loginFlag", 2),
		// Constant.REQUESTCODE_LOGIN_CODE);
		// }
	}

	private void setVideoPath(String path) {
		Logger.i(TAG, "setVideoPath_path=" + path);
		if (path.startsWith("http:")) {
			isOnline = true;
			Logger.i(TAG, "isOnline==true");
			// vv_video.setVideoURI(Uri.parse(path));
			vv_video.setVideoURI(Uri.parse(path));
		} else {
			isOnline = false;
			Logger.i(TAG, "isOnline==false");
			vv_video.setVideoPath(path);
		}
	}

	private void setListenerForVideoview() {

		seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

			// 当拖动发生改变的时候执行
			@Override
			public void onProgressChanged(SeekBar seekbar, int progress,
					boolean fromUser) {
				if (fromUser) {
					vv_video.seekTo(progress);
					timeTv.setText(Utils.millisToString(progress));
				}

			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
				handler.removeMessages(SEND_LOG);
			}

			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
				handler.sendEmptyMessage(SEND_LOG);
			}
		});
		// 解决2.3系统中混动surfaceview有黑边的问题
		vv_video.setZOrderMediaOverlay(true);
		vv_video.getHolder().setFormat(PixelFormat.TRANSPARENT);

		vv_video.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				Logger.i("ontouch", "event.getAction()=" + event.getAction());
				switch (event.getAction()) {
				case MotionEvent.ACTION_UP:
					break;
				case MotionEvent.ACTION_DOWN: // 临时这样处理吧，这个被播放器拦截了，全屏和小平有冲突
					if (isMoreValue) {
						return false;
					}
					if (!overlayShowing) {
						showOverlay();
						// showOverlayNo();
					} else {
						hideOverlay(false);
					}
					break;
				}
				return false;
			}
		});

		vv_video.setOnSeekCompleteListener(new OnSeekCompleteListener() {

			@Override
			public void onSeekComplete(MediaPlayer mp) {
			}
		});

		/**
		 * 监听播放出错时的处理
		 */
		vv_video.setOnErrorListener(new OnErrorListener() {

			@Override
			public boolean onError(MediaPlayer mp, int what, int extra) {
				Logger.i(TAG, "what=" + what + ",extra=" + extra);
				if (vv_video != null) {
					vv_video.pause();
					position = vv_video.getCurrentPosition();
					vv_video.stopPlayback();
					switch (extra) {// extra的错误码很奇怪，没有匹配的，基本上都走default
					case MediaPlayer.MEDIA_ERROR_IO:
//						ToastAlone.showToast(PaikeVideoDetailActivity.this,
//								"视频源或网络错误", 1);
						if (videoInfo != null) {
							setVideoPath(videoInfo.getVideoUrl());
						}
						break;
					case MediaPlayer.MEDIA_ERROR_MALFORMED:
						ToastAlone.showToast(PaikeVideoDetailActivity2.this,
								"视频编码或文件错误", 1);
						break;
					case MediaPlayer.MEDIA_ERROR_UNSUPPORTED:
						ToastAlone.showToast(PaikeVideoDetailActivity2.this,
								"视频格式不支持", 1);
						break;
					case MediaPlayer.MEDIA_ERROR_TIMED_OUT:
						if (videoInfo != null) {
							handler.removeMessages(SEND_LOG);
							// 设置播放视频源的路径
							setVideoPath(videoInfo.getVideoUrl());
							ToastAlone.showToast(PaikeVideoDetailActivity2.this,
									"视频请求超时，正在重新请求", 1);
						}
						break;
					default:
						handler.removeMessages(SEND_LOG);
						ToastAlone.showToast(PaikeVideoDetailActivity2.this,
								"视频播放未知错误", 1);
						break;
					}

				}
				return true;
			}
		});

		vv_video.setSizeChangeLinstener(new SizeChangeLinstener() {

			@Override
			public void doMyThings() {
				// setVideoScale(SCREEN_DEFAULT);
				// setVideoDefauleScale();
			}
		});

		vv_video.setOnPreparedListener(new OnPreparedListener() {

			@Override
			public void onPrepared(MediaPlayer arg0) {
				if (isHasUrl) {
					Message message = Message.obtain();
					message.what = STATE_GET_VIDEODATA;
					handler.sendMessage(message);
				}
				if (!overlayShowing) {
					showOverlay();
				}
				// setVideoScale(SCREEN_DEFAULT);
				// setVideoDefauleScale();

				int i = vv_video.getDuration();
				duration = i;

				Logger.d(TAG, "duration=" + i);
				// 视频文件和seekBar关联：视频有多长那么seekBar拖动也在这个范围内
				seekbar.setMax(i);
				Logger.i(TAG, "position=" + position);
				vv_video.seekTo(position);
				if (position == 0) {
					vv_video.seekTo(1);// ft_8.29笨方法
				}
				timeTv.setText(Utils.millisToString(position));
				lengthTv.setText(Utils.millisToString(i));
				// lengthTv.setText(""+Utility.getDuration(""+i/1000));
				// txtDuration.setText(" "+Utils.millisToString(i));
				if (isAutoPlay || clickPlay) {
					if (isGotoComment) {
						isGotoComment = false;
					} else {
						Logger.i(TAG,
								"vv_video.setOnPreparedListener方法里下一步videoStart了");
						videoStart();
						videoPlayUpToServer("0", "0");
					}
					clickPlay = false;
				} else {
					videoPause();
				}

				// startPlay(isAutoPlay);
			}
		});

		vv_video.setOnCompletionListener(new OnCompletionListener() {

			@Override
			public void onCompletion(MediaPlayer arg0) {
				position = 0;
				vv_video.seekTo(position);
				seekbar.setProgress(position);
				timeTv.setText(String.format("%02d:%02d", 0, 0));

				updateVideoPalyerUI(false);
				videoPlayUpToServer("2", vv_video.getDuration() / 1000 + "");
				if (listVideoAbout != null && listVideoAbout.size() > 0) {
					VideoDetailInfoNew4 info=listVideoAbout.get(0);
					if(!TextUtils.isEmpty(info.getVideoId())){
						if (isAutoPlay) {
							clickPlay = true;
						} else {
							clickPlay = false;
						}
						getVideoDetail(info.getVideoId());
					}
				}
			}
		});

		vv_video.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {

			@Override
			public void onBufferingUpdate(MediaPlayer mp, int percent) {
				// loadRateView.setText(percent + "%");
				loadRate = percent;
			}
		});

	}

	/**
	 * show overlay the the default timeout
	 */
	private void showOverlay() {
		showOverlay(OVERLAY_TIMEOUT);
	}

	/**
	 * show overlay
	 */
	private void showOverlay(int timeout) {
		if (!overlayShowing) {
			overlayShowing = true;
			// mOverlayHeader.setVisibility(View.VISIBLE);
			layout_overback.setVisibility(View.VISIBLE);
			// mOverlay.setVisibility(View.VISIBLE);
			// playVideo.setVisibility(View.VISIBLE);
		}
		Message msg = handler.obtainMessage(FADE_OUT);
		if (timeout != 0) {
			handler.removeMessages(FADE_OUT);
			handler.sendMessageDelayed(msg, timeout);
		}
	}

	/**
	 * show overlay
	 */
	private void showOverlayNo() {
		if (!overlayShowing) {
			overlayShowing = true;
			// mOverlayHeader.setVisibility(View.VISIBLE);
			layout_overback.setVisibility(View.VISIBLE);
			// mOverlay.setVisibility(View.VISIBLE);
			// playVideo.setVisibility(View.VISIBLE);
		}
	}

	/**
	 * hider overlay
	 */
	private void hideOverlay(boolean fromUser) {
		if (overlayShowing) {
			// if (!fromUser) {
			// mOverlayHeader.startAnimation(AnimationUtils.loadAnimation(
			// this, android.R.anim.fade_out));
			// mOverlay.startAnimation(AnimationUtils.loadAnimation(this,
			// android.R.anim.fade_out));
			// }
			// mOverlayHeader.setVisibility(View.INVISIBLE);
			// mOverlay.setVisibility(View.INVISIBLE);
			// playVideo.setVisibility(View.INVISIBLE);
			layout_overback.setVisibility(View.GONE);
			overlayShowing = false;
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		MobclickAgent.onPageStart("拍客视频详情页");
		MobclickAgent.onResume(this);
		PersonalOptionActivity.isClearMemory = false;
		isCanPlay = true;

		if (unlockflag && vv_video != null || (!isFullBack && vv_video != null)) {
			unlockflag = false;
			videoStart();
		}

	}

	@Override
	public void onPause() {
		super.onPause();
		MobclickAgent.onPageEnd("拍客视频详情页");
		MobclickAgent.onPause(this);
		isCanPlay = false;
		videoPause();
		closeMoreLl();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		if (vv_video != null) {
			vv_video.stopPlayback();
			vv_video = null;
		}
		unregisterReceiver(unlockScreenReceiver);
		unlockScreenReceiver = null;
		unregisterReceiver(lockScreenReceiver);
		lockScreenReceiver = null;
		this.finish();
		System.gc();
	}

	/**
	 * 锁屏广播接收者
	 */
	private class LockScreenReceiver extends BroadcastReceiver {

		@Override
		public void onReceive(Context context, Intent intent) {
			unlockflag = false;
			Logger.i(TAG, "锁屏了");
		}
	}

	/**
	 * 解锁广播接收者
	 */
	private class UnlockScreenReceiver extends BroadcastReceiver {

		@Override
		public void onReceive(Context context, Intent intent) {
			unlockflag = true;
			Logger.i(TAG, "屏幕解锁了");
		}

	}

	/**
	 * 设置视频播放屏幕大小的模式
	 * 
	 * @param flag
	 */
	private void setVideoDefauleScale() {// ft_9.16方法修改，来源外包(潘鑫)，

		// int videoWidth = vv_video.getVideoWidth();
		// int videoHeight = vv_video.getVideoHeight();
		int mWidth = screenWidth;
		// double ar = (double) videoWidth / (double) videoHeight;
		int mHeight = (int) (mWidth * 9 / 16);
		LayoutParams layoutParams = videoViewRl.getLayoutParams();
		layoutParams.height = mHeight;
		layoutParams.width = mWidth;
		videoViewRl.setLayoutParams(layoutParams);
		vv_video.setVideoScale(mWidth, mHeight);

		LayoutParams layoutParamsMore = layoutMoreBack.getLayoutParams();
		layoutParams.height = mHeight;
		layoutParams.width = screenWidth;
		layoutMoreBack.setLayoutParams(layoutParamsMore);
	}

	/**
	 * 设置视频播放横屏
	 * 
	 * @param flag
	 */
	private void setVideoDefauleScaleLandScape() {// ft_9.16方法修改，

		// int videoWidth = vv_video.getVideoWidth();
		// int videoHeight = vv_video.getVideoHeight();
		int mWidth = screenHeight;
		// double ar = (double) videoWidth / (double) videoHeight;
		int mHeight = screenWidth;
		LayoutParams layoutParams = videoViewRl.getLayoutParams();
		layoutParams.height = mHeight;
		layoutParams.width = mWidth;
		videoViewRl.setLayoutParams(layoutParams);
		vv_video.setVideoScale(mWidth, mHeight);

		LayoutParams layoutParamsMore = layoutMoreBack.getLayoutParams();
		layoutParams.height = mHeight;
		layoutParams.width = mWidth;
		layoutMoreBack.setLayoutParams(layoutParamsMore);

	}

	private void setUiFullScreen() {
		descTv.setVisibility(View.GONE);
		layout_zanBack.setVisibility(View.GONE);
		viewUser1.setVisibility(View.GONE);
//		viewUser2.setVisibility(View.GONE);
		viewUser3.setVisibility(View.GONE);
		viewAdv1.setVisibility(View.GONE);
		viewAdv2.setVisibility(View.GONE);
		viewAdv3.setVisibility(View.GONE);
		line_8.setVisibility(View.GONE);
		line_9.setVisibility(View.GONE);
		line_10.setVisibility(View.GONE);
		line_11.setVisibility(View.GONE);
		line_12.setVisibility(View.GONE);
//		layoutUserInfoBack.setVisibility(View.GONE);
		layoutVideoAdBack.setVisibility(View.GONE);
		layoutAboutVideoBack.setVisibility(View.GONE);
		aboutLv.setVisibility(View.GONE);
		layoutCommentTitleBack.setVisibility(View.GONE);
		layoutCommentWriteTipsBack.setVisibility(View.GONE);
		mLayComment.setVisibility(View.GONE);
		// commentAdapter
		// comment.setAdapter(null);
		View decorView = getWindow().getDecorView();
		// Hide both the navigation bar and the status bar.
		// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and
		// higher, but as
		// a general rule, you should design your app to hide the status bar
		// whenever you
		// hide the navigation bar.
		// int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
		// | View.SYSTEM_UI_FLAG_FULLSCREEN;
		int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
		// int uiOptions = View.INVISIBLE;
		decorView.setSystemUiVisibility(uiOptions);
	}

	private void setUiScreenWithTitle() {
		descTv.setVisibility(View.VISIBLE);
		layout_zanBack.setVisibility(View.VISIBLE);
		viewUser1.setVisibility(View.VISIBLE);
//		viewUser2.setVisibility(View.VISIBLE);
		viewUser3.setVisibility(View.VISIBLE);
		viewAdv1.setVisibility(View.VISIBLE);
		viewAdv2.setVisibility(View.VISIBLE);
		viewAdv3.setVisibility(View.VISIBLE);
		line_8.setVisibility(View.VISIBLE);
		line_9.setVisibility(View.VISIBLE);
		line_10.setVisibility(View.VISIBLE);
		line_11.setVisibility(View.VISIBLE);
		line_12.setVisibility(View.VISIBLE);
//		layoutUserInfoBack.setVisibility(View.VISIBLE);
		layoutVideoAdBack.setVisibility(View.VISIBLE);
		layoutAboutVideoBack.setVisibility(View.VISIBLE);
		aboutLv.setVisibility(View.VISIBLE);
		layoutCommentTitleBack.setVisibility(View.VISIBLE);
		layoutCommentWriteTipsBack.setVisibility(View.VISIBLE);
		mLayComment.setVisibility(View.VISIBLE);
		// commentPlv.setVisibility(View.VISIBLE);
		// comment.setAdapter(commentAdapter);
		View decorView = getWindow().getDecorView();
		// Hide both the navigation bar and the status bar.
		// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and
		// higher, but as
		// a general rule, you should design your app to hide the status bar
		// whenever you
		// hide the navigation bar.
		// int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
		// | View.SYSTEM_UI_FLAG_FULLSCREEN;
		int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE;
		decorView.setSystemUiVisibility(uiOptions);
	}

	// /**
	// * 设置视频播放屏幕大小的模式
	// *
	// * @param flag
	// */
	// private void setVideoDefauleScale() {
	//
	// int videoWidth = vv_video.getVideoWidth();
	// int videoHeight = vv_video.getVideoHeight();
	// int mWidth = screenWidth;
	// int mHeight = screenHeight;
	//
	// // calculate aspect ratio
	// double ar = (double) videoWidth / (double) videoHeight;
	// // calculate display aspect ratio
	// double dar = (double) mWidth / (double) mHeight;
	// if (dar < ar)
	// mHeight = (int) (mWidth / ar);
	// else
	// mWidth = (int) (mHeight * ar);
	// // mHeight = mWidth;
	//
	// vv_video.setVideoScale(mWidth, mHeight);
	// }

	// /**
	// * 结束。开始时使用，是否自动播放
	// */
	// protected void startPlay(boolean autoPlay) {
	//
	// if (autoPlay) {
	// videoStart();
	// } else {
	// updateVideoPalyerUI(false);
	// }
	// }

	/**
	 * 暂停。继续播放使用
	 */
	private void updatePausePlay() {

		if (vv_video.isPlaying()) {
			videoPause();
		} else {
			clickPlay = true;
			videoStart();
		}
	}

	private void videoStart() {
		isGotoComment = false;
		if (isCanPlay) {
			isPause = false;

			vv_video.start();
			updateVideoPalyerUI(true);
		}
	}

	private void videoPause() {
		clickPlay = false;
		isPause = true;
		vv_video.pause();
		updateVideoPalyerUI(false);
	}

	/**
	 * 修改播放器ui
	 * 
	 * @param isPlay
	 *            是否正在播放，true播放，false未播放
	 */
	private void updateVideoPalyerUI(boolean isPlay) {

		handler.removeMessages(SHOW_PROGRESS);
		handler.removeMessages(SEND_LOG);
		playVideo.setVisibility(View.VISIBLE);
		if (isPlay) {
			// playVideo.setImageResource(R.drawable.ic_media_pause);
			playVideo.setImageResource(R.drawable.btn_play_video_pause);
			// playIv.setVisibility(View.GONE);
			handler.sendEmptyMessage(SHOW_PROGRESS);
			handler.sendEmptyMessageDelayed(SEND_LOG, sLogTimeout);
		} else {
			waitingLl.setVisibility(View.GONE);
			// playVideo.setImageResource(R.drawable.icon_play_mini);
			playVideo.setImageResource(R.drawable.btn_play_video);
			// playIv.setVisibility(View.VISIBLE);
		}
	}

	/**
	 * 显示分享弹出框
	 */
	private void showShareLl() {
		videoPause();
		showShareBack();
	}

	/** 分享到微信0:朋友圈，1 微信好友 */
	private void onkeyshareWEiXin(int type) {
		if (videoInfo != null) {
			String url = Constant.PAIKE_VIDEO_SHARE_URL + videoInfo.getImgUrl()
					+ "&videoURL=" + videoInfo.getVideoUrl();

			WXVideoObject video = new WXVideoObject();
			if (videoInfo.getWabSiteUrl() != null
					&& videoInfo.getWabSiteUrl().length() > 6) {
				video.videoUrl = videoInfo.getWabSiteUrl();
			} else {
				video.videoUrl = url;
			}
			String content = "\""
					+ videoInfo.getTitle()
					+ "\""
					+ "点此播放"
					+ "\""
					+ video.videoUrl
					+ "\""
					+ "（通过＃第一视频＃分享，@第一视频，聚合全球海量有趣有料有用的精选短视频，助你大开眼界！下载猛戳http://apps.v1.cn）";
			WXMediaMessage msg = new WXMediaMessage(video);
			msg.title = videoInfo.getTitle();
			// msg.description = videoInfo.getDetail();
			msg.description = content;

			Bitmap thumb = BitmapFactory.decodeResource(getResources(),
					R.drawable.ic_launcher);
			msg.thumbData = com.v1.video.util.Util.bmpToByteArray(thumb, true);

			SendMessageToWX.Req req = new SendMessageToWX.Req();
			req.transaction = buildTransaction("video");
			req.message = msg;
			req.scene = type == 0 ? SendMessageToWX.Req.WXSceneTimeline
					: SendMessageToWX.Req.WXSceneSession;
			// req.scene = isTimelineCb.isChecked() ?
			// SendMessageToWX.Req.WXSceneTimeline :
			// SendMessageToWX.Req.WXSceneSession;
			api.sendReq(req);

			Constant.setShare(true);
			Constant.listenerShare.init(PaikeVideoDetailActivity2.this, null);
		} else {
			ToastAlone.showToast(PaikeVideoDetailActivity2.this, "未获取到分享内容", 0);
		}
	}

	private String buildTransaction(final String type) {
		return (type == null) ? String.valueOf(System.currentTimeMillis())
				: type + System.currentTimeMillis();
	}

	/**
	 * QQ空间和QQ
	 * 
	 * @param v
	 * @param plat
	 */
	private void onkeyshareQQ(View v, Platform plat) {
		if (videoInfo != null) {
			// String content = "第一视频推出，可以随时随地记录和分享身边发生的事，随时看新闻";
			// String content = "第一视频，随看随拍随分享，让发现随时！";

			String url = Constant.PAIKE_VIDEO_SHARE_URL + videoInfo.getImgUrl()
					+ "&videoURL=" + videoInfo.getVideoUrl();
			if (videoInfo.getWabSiteUrl() != null
					&& videoInfo.getWabSiteUrl().length() > 5) {
				url = videoInfo.getWabSiteUrl();
			}
			String content = "\""
					+ videoInfo.getTitle()
					+ "\""
					+ "点此播放"
					+ "\""
					+ url
					+ "\""
					+ "（通过＃第一视频＃分享，@第一视频，聚合全球海量有趣有料有用的精选短视频，助你大开眼界！下载猛戳http://apps.v1.cn）";
			ShareParams sp = new ShareParams();
			// sp.setShareType(Platform.SHARE_VIDEO);
			// sp.setShareType(Platform.SHARE_WEBPAGE);
			sp.setShareType(Platform.SHARE_IMAGE);
			sp.setTitle(videoInfo.getTitle());
			// sp.setTitleUrl("i.apps.v1.cn");
			sp.setTitleUrl(url);
			sp.setText(content);
			// sp.setUrl(url);
			Logger.i("json", "拍客视频url=" + url);

			Logger.i("sharesdk", "title:" + videoInfo.getTitle());
			Logger.i("sharesdk", "url:" + url);
			Logger.i("sharesdk", "content:" + content);
			sp.setImageUrl(videoInfo.getImgUrl());
			String userid = null;
			if (LoginInfo.getInstance().isLogin())
				userid = LoginInfo.getInstance().getUserId();
			plat.setPlatformActionListener(new SharePlatformActionListener(
					PaikeVideoDetailActivity2.this, null));
			plat.share(sp);
		} else {
			ToastAlone.showToast(PaikeVideoDetailActivity2.this, "未获取到分享内容", 0);
		}
	}

	/**
	 * sina微博，tencent微博
	 * 
	 * @param v
	 * @param plat
	 * @param content
	 */
	private void onkeyshare(View v, Platform plat, String content) {
		if (videoInfo != null) {
			// String shareV1 = "#第一视频#@第一视频 ";
			// String url
			// =Constant.PAIKE_VIDEO_SHARE_URL+videoInfo.getImgUrl()+"&videoURL="+videoInfo.getVideoUrl();
			ShareParams sp = new ShareParams();

			sp.setShareType(Platform.SHARE_IMAGE);
			// if(videoInfo.getWabSiteUrl() != null &&
			// videoInfo.getWabSiteUrl().length() > 5){
			// sp.setText(shareV1 + content + videoInfo.getWabSiteUrl());
			// }else{
			// sp.setText(shareV1 + content + videoInfo.getVideoUrl());
			// }
			sp.setTitle(videoInfo.getTitle());
			sp.setText(content);
			sp.setImageUrl(videoInfo.getImgUrl()); // 直接分享网络地址
			String userid = null;
			if (LoginInfo.getInstance().isLogin())
				userid = LoginInfo.getInstance().getUserId();
			plat.setPlatformActionListener(new SharePlatformActionListener(
					PaikeVideoDetailActivity2.this, null));
			plat.share(sp);
		} else {
			ToastAlone.showToast(PaikeVideoDetailActivity2.this, "未获取到标题", 0);
		}
	}

	/**
	 * 显示更多
	 */
	private void showMoreLl() {
		videoPause();
		if (isOnSelf) {
			showMoreLayoutOnSelf();
		} else {
			// showMoreLayout();
			showMoreLayout(0);
		}

	}

	/**
	 * 隐藏更多
	 */
	private void closeMoreLl() {
		// moreTv.setCompoundDrawablesWithIntrinsicBounds(0,
		// R.drawable.btn_more_selecter, 0, 0);
		// if (moreLl != null && moreLl.isShown()) {
		// moreLl.setVisibility(View.GONE);
		// }
	}

	private String strShareTitle = "";

	/**
	 * 分享弹出框
	 * 
	 * @param context
	 * @param id
	 * @param type
	 *            0:新浪，1，腾讯微博 2，两个一起
	 */
	public void showSharedDialog(final Context context, final int type) {
		// 暂停视频播放
		isCanPlay = false;
		videoPause();
		View shareView = View.inflate(context, R.layout.dialog_one_key_share,
				null);
		final Dialog dialog = new Dialog(context, R.style.dialog_custom);
		Display display = getWindowManager().getDefaultDisplay();
		int width = display.getWidth();
		LayoutParams params = new LayoutParams((int) (width * 0.9),
				ViewGroup.LayoutParams.MATCH_PARENT);
		dialog.setContentView(shareView, params);
		dialog.setCancelable(true);

		final EditText contentEt = (EditText) shareView
				.findViewById(R.id.tv_shared_content);
		final TextView contentNum = (TextView) shareView
				.findViewById(R.id.tv_content_num);

		final View sinaSelect = shareView.findViewById(R.id.rl_sina);
		final View qqSelect = shareView.findViewById(R.id.rl_qq_share);
		contentEt.setText(strShareTitle);
		if (type == 0) {
			qqSelect.setVisibility(View.GONE);
		} else if (type == 1) {
			sinaSelect.setVisibility(View.GONE);
		} else if (type == 2) {
		}

		if (!strShareTitle.equals("")) {
			String number = Utils.calculateLength(strShareTitle) + "/"
					+ TEXT_LENGTH;
			contentNum.setText(number);
		} else {
			contentNum.setText("0/" + TEXT_LENGTH);
		}

		contentEt.addTextChangedListener(new TextWatcher() {
			private CharSequence temp;
			private int selectionStart;
			private int selectionEnd;

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				temp = s;
			}

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
			}

			@Override
			public void afterTextChanged(Editable s) {
				String number = Utils.calculateLength(s) + "/" + TEXT_LENGTH;
				contentNum.setText(number);
				selectionStart = contentEt.getSelectionStart();
				selectionEnd = contentEt.getSelectionEnd();
				if (Utils.calculateLength(temp) > TEXT_LENGTH) {
					s.delete(
							(selectionStart - (int) (Utils.calculateLength(s) - TEXT_LENGTH)),
							selectionEnd);
					contentEt.setText(s);
					contentEt.setSelection(selectionStart);// 设置光标
				}
			}
		});

		shareView.findViewById(R.id.tv_share).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						String contentStr = contentEt.getText().toString()
								.trim();

						if (!TextUtils.isEmpty(contentStr)) {

							onkeyshare(v, ShareSDK.getPlatform(
									PaikeVideoDetailActivity2.this,
									SinaWeibo.NAME), contentStr);
							dialog.dismiss();

						} else {
							ToastAlone.showToast(PaikeVideoDetailActivity2.this,
									R.string.share_content_not_null, 0);

						}

					}
				});
		shareView.findViewById(R.id.close_account_cancel).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						dialog.dismiss();
					}
				});
		shareView.findViewById(R.id.iv_cleanup).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						contentEt.setText("");
						contentNum.setText("0/" + TEXT_LENGTH);
					}
				});

		dialog.setOnDismissListener(new OnDismissListener() {

			@Override
			public void onDismiss(DialogInterface dialog) {
				isCanPlay = true;
			}
		});
		dialog.show();
	}

	/**
	 * 查询是否举报
	 * 
	 * @param userId
	 * @param videoId
	 */
	private void quertVideoReport(String userId, String videoId) {
		// if (isReport == null) {
		// new QueryVideoReportAsync(userId, videoId).execute();
		getQueryTheVideoReported(videoId);
		// }
	}

	/**
	 * 查询是否收藏
	 * 
	 * @param userId
	 * @param videoId
	 */
	private void quertVideoCollect(String userId, String videoId) {
		// if (isCollect == null) {
		// new QueryVideoCollectionAsync(userId, videoId).execute();
		getQueryTheVideoCollection(videoId);
		// }
	}

	private void processVideoDetail(
			PaikeVideoDetailPageInfo4 paikeVideoPageInfo, int type) {

		if (paikeVideoPageInfo != null && Constant.CODE_RESULT_SUCCESS == type) {
			Logger.i(TAG, "成功加载了！！");
			// videoInfo = paikeVideoInfo;
			final PaikeVideoDetailPageObj4 obj = paikeVideoPageInfo.getObj();
			if (obj == null) {
				ToastAlone
						.showToast(PaikeVideoDetailActivity2.this, "未查询到结果", 1);
				return;
			}
			if (obj.getVideoDetail() == null) {
				ToastAlone
						.showToast(PaikeVideoDetailActivity2.this, "未查询到结果", 1);
				return;
			}
			videoInfo = new VPaikeVideoInfo(obj.getVideoDetail());
			// videoInfo.setFocusOntype(""+obj.getUserFocusOnType());
			Logger.i(TAG, "videoInfourl=" + videoInfo.getVideoUrl());
//			setAttentionViewState(videoInfo.getFocusOntype());
			String playNum = videoInfo.getPlaynum();
			if (playNum != null && !playNum.equals("")) {

				txtPlayNum.setText(videoInfo.getPlaynum());
			} else {
				txtPlayNum.setText("0");
			}

			
			if(TextUtils.isEmpty(source_name)){
				tv_source.setText("视频来源："+videoInfo.getUserName());
			}else{
			}
			SetHead setHead = new SetHead();

			ImageLoader.getInstance().displayImage(videoInfo.getImgUrl(),
					new ImageView(PaikeVideoDetailActivity2.this),
					Constant.IMAGE_OPTIONS_FOR_VIDEO);
			String userName = videoInfo.getUserName();
			if (userName != null && userName.length() > 9) {
				userName = userName.substring(0, 6) + "...";
			}

			if (LoginInfo.getInstance().isLogin()) {// 这区域用于去获取关注关系
				if (videoInfo.getUserId() != null
						&& videoInfo.getUserId().length() >= 1) {
					Message message = Message.obtain();
					message.what = STATE_FOCOUS_OF_USER;
					message.obj = videoInfo.getUserId();
					handler.sendMessage(message);
				} else {
					if (obj.getVideoDetail().getUserInfo() != null) {
						if (obj.getVideoDetail().getUserInfo().getUserId() != null) {
							Message message = Message.obtain();
							message.what = STATE_FOCOUS_OF_USER;
							message.obj = obj.getVideoDetail().getUserInfo()
									.getUserId()
									+ "";
							handler.sendMessage(message);
						}
					}
				}
			}

			Logger.i(TAG,
					"videoInfo.getCreate_time()=" + videoInfo.getCreate_time());
			descTv.setText(videoInfo.getTitle());
			if (!isHasUrl) {
				String path = videoInfo.getVideoUrl();
				Logger.i(TAG, "视频播放路径path=" + path);
				if (TextUtils.isEmpty(path)) {
					videoViewRl.setVisibility(View.GONE);
				} else {
					setVideoPath(path);
					if (isAutoPlay && isCanPlay) {
						Logger.i(TAG, "下面执行videoStart");
						// videoStart();
						updateVideoPalyerUI(true);
					}
					videoViewRl.setVisibility(View.VISIBLE);
					Message message = Message.obtain();
					message.what = STATE_GET_COURSE;
					handler.sendMessage(message);
				}
			} else {
				Message message = Message.obtain();
				message.what = STATE_GET_COURSE;
				handler.sendMessage(message);
//				layoutUserInfoBack.setVisibility(View.VISIBLE);
				layout_zanBack.setVisibility(View.VISIBLE);
//				viewUser2.setVisibility(View.VISIBLE);
				viewUser3.setVisibility(View.VISIBLE);
			}
			listVideoAbout = obj.getRelatedVideoDetails();// 推荐
			if (listVideoAbout != null && !listVideoAbout.isEmpty()) {
				aboutLv.setVisibility(View.VISIBLE);
				layoutAboutVideoBack.setVisibility(View.VISIBLE);
				AdapterVideoAboutList aboutAdapter = new AdapterVideoAboutList();
				// galleryVidelAboutList.setAdapter(aboutAdapter);
				LayoutParams layoutParams = aboutLv.getLayoutParams();
				float height = this.getResources().getDimension(
						R.dimen.classify_item_image_height)
						+ this.getResources().getDimension(
								R.dimen.classify_item_padding) * 2;
				// layoutParams.height = DensityUtil.dip2px(
				// PaikeVideoDetailActivity.this,
				// 106 * listVideoAbout.size());
				layoutParams.height = (int) (height * listVideoAbout.size());
				layoutParams.width = LayoutParams.MATCH_PARENT;
				aboutLv.setLayoutParams(layoutParams);
				aboutLv.setAdapter(aboutAdapter);
				aboutLv.setOnItemClickListener(new OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						// TODO Auto-generated method stub
						final VideoDetailInfoNew4 videoInfo = listVideoAbout
								.get(position);
						clickStatistics(Constant.VIDEODETAIL_RELEVANCE_ID,
								"视频详情页的相关视频_" + videoInfo.getTitle());
						ScenarioVideoInfo video = new ScenarioVideoInfo(
								videoInfo);
						if(new_toast != null){
							new_toast.cancel();
						}
						if (video != null) {
							Intent intent = new Intent(
									PaikeVideoDetailActivity2.this,
									PaikeVideoDetailActivity2.class);
							intent.putExtra("videoInfo", video);
							intent.putExtra("source",
									Constant.ADV_SOURCE_PLAYDETAIL);
							PaikeVideoDetailActivity2.this.startActivity(intent);
						}
						PaikeVideoDetailActivity2.this.finish();
					}
				});
			} else {
				aboutLv.setVisibility(View.GONE);
				layoutAboutVideoBack.setVisibility(View.GONE);
			}
			layoutLl.setVisibility(View.VISIBLE);
		} else {
			ToastAlone.showToast(PaikeVideoDetailActivity2.this, "未查询到结果", 1);
			finish();
		}

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode == RESULT_OK && data != null) {
			Logger.i(TAG, "onActivityResult返回了");
			switch (requestCode) {
			case Constant.REQUESTCODE_LOGIN_CODE:
				// videoStart();
				playVideo.setVisibility(View.VISIBLE);
				if (data.getBooleanExtra("login", false)
						&& LoginInfo.getInstance().isLogin()
						&& scenarioVideoInfo != null) {
					// new
					// GetVideoDetailAsync(scenarioVideoInfo.getVideoId(),//ft_11.26优化去掉
					// LoginInfo.getInstance().getUserId()).execute();
					initVideoCollectAndReport(LoginInfo.getInstance()
							.getUserId(), scenarioVideoInfo.getVideoId());
				}
				break;

			case Constant.REQUESTCODE_COMMENT_CODE:
				// 刷新数据
				Logger.i(TAG, "评论返回了");
				if (data.getBooleanExtra("login", false)
						&& LoginInfo.getInstance().isLogin()
						&& scenarioVideoInfo != null) {
					// new
					// GetVideoDetailAsync(scenarioVideoInfo.getVideoId(),//ft_11.26优化去掉
					// LoginInfo.getInstance().getUserId()).execute();
					// initVideoCollectAndReport(LoginInfo.getInstance()
					// .getUserId(), scenarioVideoInfo.getVideoId());
				}
				break;
			case Constant.REQUESTCODE_FULL_SCREEN:
				position = data.getIntExtra("position", 0);
				vv_video.seekTo(position);
				Logger.i(TAG, "position ==" + position);
				isFullBack = data.getBooleanExtra("isPause", true);// ft_9.11
				if (isFullBack) {
					isAutoPlay = false;
				} else {
					isAutoPlay = true;
					videoStart();
				}
				break;
			case Constant.REQUESTCODE_OTHERPERSON_CODE:
				String focusOntype = data.getStringExtra("focusOntype");
				if (!TextUtils.isEmpty(focusOntype)) {
					videoInfo.setFocusOntype(focusOntype);
//					setAttentionViewState(focusOntype);
				}
				break;
			case Constant.REQUEST_CODE_VIDEO_CAPTURE:
				Uri outputUri = data.getData();// 文件uri
				if (outputUri != null) {
					ToastAlone.showToast(PaikeVideoDetailActivity2.this,
							"拍摄保存成功,可在相册中查看", 1);
					// XiaoyingUtils.insertRecord(PaikeVideoDetailActivity.this,
					// outputUri.toString());
					startActivity(new Intent(PaikeVideoDetailActivity2.this,
							SaveShareActivity.class).putExtra("videoUri",
							outputUri).putExtra(Constant.RELATED_VIDEO_ID,
							relatedVideoId));
				}

				break;
			case Constant.REQUEST_CODE_PAIKE_VIDEO_COMMENT:
				boolean refresh = data.getBooleanExtra("refresh", false);
				if (refresh) {

					Logger.i(TAG, "评论返回了0000000000000000000");
					curPage = 0;
					// new GetHeaderDataTask(true).execute();
//					getTheVideoComment(scenarioVideoInfo.getVideoId(), curPage);
					// new
					// GetVideoDetailAsync(scenarioVideoInfo.getVideoId(),//ft_11.26优化去掉
					// LoginInfo.getInstance().getUserId()).execute();
					// initVideoCollectAndReport(LoginInfo.getInstance()
					// .getUserId(), scenarioVideoInfo.getVideoId());
				}
				break;
			case STATE_RETURN_LOGIN_REWARD:
				openPayActivity(videoInfo.getTitle(), videoMoney,
						videoInfo.getVideoId(), videoInfo.getDetail());
				break;
			case Constant.REQUEST_COMMENT_CODE:
				if (LoginInfo.getInstance().isLogin()) {
					showSendCommentDialog(mCommentId, mReplyName);
				}
				break;
			}
		}

		relatedVideoId = "";
	}


	private class Commentdapterr extends BaseAdapter {

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ContentViewHolder holder = null;
			if (convertView != null && convertView instanceof LinearLayout)
				holder = (ContentViewHolder) convertView.getTag();
			else {
				holder = new ContentViewHolder();
				convertView = View.inflate(PaikeVideoDetailActivity2.this,
						R.layout.item_video_comment, null);
				holder.nickName = (TextView) convertView
						.findViewById(R.id.tv_nickname);
				holder.content = (TextView) convertView
						.findViewById(R.id.tv_content);
				holder.time = (TextView) convertView.findViewById(R.id.tv_time);
				// holder.praise = (TextView)
				// convertView.findViewById(R.id.tv_praise);
				holder.head = (ImageView) convertView
						.findViewById(R.id.iv_head);
				holder.head_v = (ImageView) convertView
						.findViewById(R.id.userHeadImg_v);
				convertView.setTag(holder);
			}

			final VPaikeCommentInfo info = commentVo.get(position);
			if (info.getModel() == 0) {
				if (info.getNickname() == null || info.getNickname().equals("")
						|| info.getNickname().equals("null")) {
					holder.nickName.setText(info.getUserName());
				} else {
					holder.nickName.setText(info.getNickname());
				}
				// Logger.i(TAG, "info.getUserName()==" + info.getUserName());
				// holder.time.setText(Utils.getFormatTime(info.getCreateTime()));
				holder.time.setText(info.getCreateTime());
				holder.content.setText(info.getComments());

				holder.head.setImageBitmap(null);
				if (info.getIsCertification() == 1) {
					holder.head_v.setVisibility(View.VISIBLE);
				} else {
					holder.head_v.setVisibility(View.GONE);
				}
				ImageLoader.getInstance().displayImage(info.getUserImg(),
						holder.head, Constant.getOption(info.getSex()),
						new SimpleImageLoadingListener() {
							@Override
							public void onLoadingComplete(String imageUri,
									View view, Bitmap loadedImage) {
								super.onLoadingComplete(imageUri, view,
										loadedImage);
								ImageView iv = (ImageView) view;
								if (loadedImage != null) {
									iv.setImageBitmap(Utils
											.toRoundBitmap(loadedImage));
									// iv.setImageBitmap(loadedImage);
								}
							}
						});

				holder.head.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						if (LoginInfo.getInstance().isLogin()) {
							if (info != null
									&& LoginInfo.getInstance().getUserId()
											.equals(info.getUserId())) {
								// startActivity(new
								// Intent(v.getContext(),PersonalCenterActivity.class));
								// startActivity(new Intent(v.getContext(),
								// PersonalHomeActivity.class));
							} else {
								gotoOtherPersonHome(info.getUserId(),
										info.getNickname(), info.getSex(), ""
												+ info.getIsCertification(),
										info.getUserImg(), info.getComments(),
										"0");
								// startActivity(new Intent(v.getContext(),
								// OtherHomeActivity.class).putExtra(
								// "userId", info.getUserId()));
							}
						} else {
							// startActivity(new Intent(v.getContext(),
							// OtherHomeActivity.class).putExtra(
							// "userId", info.getUserId()));
							gotoOtherPersonHome(info.getUserId(),
									info.getNickname(), info.getSex(), ""
											+ info.getIsCertification(),
									info.getUserImg(), info.getComments(), "0");
						}

					}
				});
			} else {// 显示暂无评论数据

			}
			return convertView;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public Object getItem(int position) {
			return commentVo.get(position);
		}

		@Override
		public int getCount() {
			return commentVo.size();
		}

	}

	private static class ContentViewHolder {
		TextView nickName;
		// TextView praise;
		TextView time;
		TextView content;
		ImageView head;
		ImageView head_v;
	}

	// 广告数据适配器
	private class AdImageAdapter extends BaseAdapter {

		private Context mCxt;
		ArrayList<CarouselInfo4> listCaroustInfo;

		public AdImageAdapter(Context cxt) {
			this.mCxt = cxt;
		}

		private AdImageAdapter(Context cxt,
				ArrayList<CarouselInfo4> listCaroustInfo) {
			this.mCxt = cxt;
			this.listCaroustInfo = listCaroustInfo;
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			if (listCaroustInfo.size() > 1) {
				return Integer.MAX_VALUE;
			} else {
				return listCaroustInfo.size();
			}
		}

		@Override
		public Object getItem(int arg0) {
			// TODO Auto-generated method stub
			return listCaroustInfo.get(arg0 % listCaroustInfo.size());
		}

		@Override
		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return arg0;
		}

		@Override
		public View getView(int arg0, View convertView, ViewGroup arg2) {
			PlaceHolder holder = null;
			if (convertView == null) {
				convertView = LayoutInflater.from(mCxt).inflate(
						R.layout.fragment_news_carousel_item, null);
				holder = new PlaceHolder();
				holder.imgView = (ImageView) convertView
						.findViewById(R.id.iv_image);
				holder.title = (TextView) convertView
						.findViewById(R.id.tv_title);
				convertView.setTag(holder);
			} else {
				holder = (PlaceHolder) convertView.getTag();
			}

			final CarouselInfo4 info = listCaroustInfo.get(arg0
					% listCaroustInfo.size());
			mIndexAdv = arg0;
			
			if(!TextUtils.isEmpty(info.getTitle())){
				holder.title.setText(info.getTitle());
			}else{
				holder.title.setText("");
			}
			if(info.getImageUrl() != null && info.getImageUrl().size()>0){
				ImageLoader.getInstance().displayImage(info.getImageUrl().get(0),
						holder.imgView, Constant.IMAGE_OPTIONS_FOR_ADVERTISEMENT,
						null);
			}
			// mAdvTxt.setText(info.getTitle());
			holder.imgView.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					clickStatistics(Constant.VIDEODETAIL_ADVERT_ID, "视频详情页的广告_"
							+ info.getTitle());
					if (info.getType() == null || info.getType().length() <= 0) {
						return;
					}
					if(new_toast != null){
						new_toast.cancel();
					}
					
					if (!Helper.checkConnection(PaikeVideoDetailActivity2.this)) {
						Toast.makeText(PaikeVideoDetailActivity2.this, R.string.net_no_notclick,
								Toast.LENGTH_SHORT).show();
						return;
					}
					if (Constant.VIDEO_TYPE_8.equals(info.getType())) {
						RequestEngine request = new RequestEngine();
						request.sendADVLogToServer(PaikeVideoDetailActivity2.this,
								Constant.STATE_ADV_CZBM_1 + "",
								Constant.STATE_ADV_CZSX_4 + "_" + info.getId(), ""
										+ Constant.STATE_ADV_CZJG_3);
						new NetEngine().AdUpToServer(PaikeVideoDetailActivity2.this, info.getAdid(),
								LoginInfo.getInstance().getUserId(), "7", "2", "-1");
					}
					TransferUtils.getInstance().transferActivity(PaikeVideoDetailActivity2.this, info.getAssociation(),info.getType(),info.getTitle(),info.getAssociation(),Constant.ADV_SOURCE_OTHER,"");
//					int type = Integer.parseInt(info.getType());
//					switch (type) {
//					case CarouselInfo4.TYPE_VIDEO:
//						Intent intent1 = new Intent(
//								PaikeVideoDetailActivity2.this,
//								PaikeVideoDetailActivity2.class);
//						intent1.putExtra("videoInfo", new ScenarioVideoInfo(
//								info.getAssociation()));
//						intent1.putExtra("source",
//								Constant.ADV_SOURCE_PLAYDETAIL);
//						startActivityHelper(intent1);
//						break;
//					case CarouselInfo4.TYPE_LINK:
//						// startActivityHelper(new Intent(mCxt,
//						// WebViewActivity2.class).putExtra("adLink",
//						// info.getAssociation()));
//						startActivityHelper(new Intent(mCxt,
//								WebViewActivity3.class).putExtra("adLink",
//								info.getAssociation()).putExtra("title",
//								info.getTitle()));
//						break;
//
//					case CarouselInfo4.TYPE_ACTIVITY:
//						break;
//					case CarouselInfo4.TYPE_TOPIC:
//						break;
//					case CarouselInfo4.TYPE_VIDEO_CATEGORY:
//						Intent intent2 = new Intent();
//						intent2.setClass(PaikeVideoDetailActivity2.this,
//								ClassificationActivity.class);
//						intent2.putExtra("title", info.getTitle());
//						intent2.putExtra("categoryId", info.getAssociation()
//								+ "");
//						intent2.putExtra("flag",
//								Constant.CLASSIFICATION_HOME_FLAG);
//						startActivityHelper(intent2);
//						break;
//					case CarouselInfo4.TYPE_ADV:
//						RequestEngine request = new RequestEngine();
//						request.sendADVLogToServer(
//								PaikeVideoDetailActivity2.this,
//								Constant.STATE_ADV_CZBM_1 + "",
//								Constant.STATE_ADV_CZSX_4 + "_" + info.getId(),
//								"" + Constant.STATE_ADV_CZJG_3);
//						if (Helper
//								.checkConnection(PaikeVideoDetailActivity2.this)) {
//							PaikeVideoDetailActivity2.this
//									.startActivity(new Intent(mCxt,
//											WebViewActivity3.class).putExtra(
//											"adLink", info.getAssociation()));
//						}
//						new NetEngine().AdUpToServer(
//								PaikeVideoDetailActivity2.this, info.getAdid(),
//								LoginInfo.getInstance().getUserId(), "7", "2",
//								"-1");
//						break;
//					default:
//						break;
//					}

				}
			});

			return convertView;
		}

		private class PlaceHolder {
			private ImageView imgView;
			private TextView title;
		}

	}

	private void startActivityHelper(Intent intent) {
		if (Helper.checkConnection(PaikeVideoDetailActivity2.this)) {
			PaikeVideoDetailActivity2.this.startActivity(intent);
			PaikeVideoDetailActivity2.this.finish();
		}
	}

	private class AdapterVideoAboutList extends BaseAdapter {

		private int mHeight;
		private int mWidth;

		public AdapterVideoAboutList() {
			mHeight = Utils.computeImageHeight(PaikeVideoDetailActivity2.this);
			mWidth = Utils.getScreenWidth(PaikeVideoDetailActivity2.this) / 2 - 4;
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return listVideoAbout.size();
		}

		@Override
		public Object getItem(int arg0) {
			// TODO Auto-generated method stub
			return listVideoAbout.get(arg0);
		}

		@Override
		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return arg0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			HolderVideoAbout holder;
			final VideoDetailInfoNew4 videoInfo = listVideoAbout.get(position);
			if (convertView == null) {
				LayoutInflater layoutInflator = LayoutInflater.from(parent
						.getContext());
				// convertView = layoutInflator.inflate(
				// R.layout.item_paike_video_list, null);
				convertView = layoutInflator.inflate(
						R.layout.activity_buddhismdetail_item, null);
				holder = new HolderVideoAbout();
				holder.image = (ImageView) convertView
						.findViewById(R.id.iv_image);
				holder.title = (TextView) convertView
						.findViewById(R.id.tv_title);
				holder.duration = (TextView) convertView
						.findViewById(R.id.tv_time);
				convertView.setTag(holder);
			}
			holder = (HolderVideoAbout) convertView.getTag();

			// android.view.ViewGroup.LayoutParams Params = holder.head
			// .getLayoutParams();
			// // Params.width = LayoutParams.MATCH_PARENT; //设置图片的宽度
			// Params.width = mWidth;
			// Params.height = mHeight;// 设置图片的高度
			holder.image.setImageBitmap(null);
			ImageLoader.getInstance().displayImage(videoInfo.getImgUrl(),
					holder.image, Constant.VIDEO_10_16_OPTION);
			holder.title.setText(videoInfo.getTitle());
			if(videoInfo.getDuration().contains(":")){
				 holder.duration.setText(videoInfo.getDuration());
			}else{
				holder.duration
				.setText(Utility.getDuration(videoInfo.getDuration()));
			}
//			holder.duration
//					.setText(Utility.getDuration(videoInfo.getDuration()));
//			 holder.duration.setText(videoInfo.getDuration());
			convertView.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					ScenarioVideoInfo video = new ScenarioVideoInfo(videoInfo
							.getVideoId() + "");
					Intent intent = new Intent();
					if (video != null) {
						intent.setClass(PaikeVideoDetailActivity2.this,
								PaikeVideoDetailActivity2.class);
						intent.putExtra("videoInfo", video);
						PaikeVideoDetailActivity2.this.startActivity(intent);
						PaikeVideoDetailActivity2.this.finish();
					}
				}
			});
			return convertView;
		}

	}

	private class HolderVideoAbout {
		TextView title;
		ImageView image;
		TextView duration;
	}

	boolean sinaflag = false;
	boolean qqWeiboflag = false;
	boolean qqflag = false;

	private CustomShareSheetDialog mSharedialog;

	/** 分享 */
	private void showShareBack() {
		clickStatistics(Constant.SHARE_ID, "视频详情页的分享");

		mSharedialog = new CustomShareSheetDialog(this);
		mSharedialog.setOnShareSheetItemClick(new OnShareSheetItemClick() {

			@Override
			public void onClick(int shareType) {
				if (mSharedialog != null && mSharedialog.isShowing()) {
					mSharedialog.dismiss();
				}
				mSharedialog = null;
				switch (shareType) {
				case CustomShareSheetDialog.TYPE_WEIXIN:
					// onkeyshare(null,
					// ShareSDK.getPlatform(PaikeVideoDetailActivity.this,
					// Wechat.NAME));
					if (api.isWXAppInstalled()) {
						onkeyshareWEiXin(1);
					} else {
						ToastAlone.showToast(PaikeVideoDetailActivity2.this,
								"亲，您尚未安装微信客户端，请下载安装~", 1);
					}
					break;
				case CustomShareSheetDialog.TYPE_QQ_SPACE:
					onkeyshareQQ(null, ShareSDK.getPlatform(
							PaikeVideoDetailActivity2.this, QZone.NAME));
					break;
				case CustomShareSheetDialog.TYPE_WEIXIN_MOMENTS:
					// onkeyshare(null,
					// ShareSDK.getPlatform(PaikeVideoDetailActivity.this,
					// WechatMoments.NAME));
					if (api.isWXAppInstalled()) {
						onkeyshareWEiXin(0);
					} else {
						ToastAlone.showToast(PaikeVideoDetailActivity2.this,
								"亲，您尚未安装微信客户端，请下载安装~", 1);
					}

					break;
				case CustomShareSheetDialog.TYPE_SINA_WEIBO:
					showSharedDialog(PaikeVideoDetailActivity2.this, 0);
					break;
				case CustomShareSheetDialog.TYPE_QQ:
					onkeyshareQQ(null, ShareSDK.getPlatform(
							PaikeVideoDetailActivity2.this, QQ.NAME));
					break;
				case CustomShareSheetDialog.TYPE_TENCET_WEIBO:
					showSharedDialog(PaikeVideoDetailActivity2.this, 1);
					break;
				case CustomShareSheetDialog.TYPE_COPY:
					ClipboardManager c = (ClipboardManager) PaikeVideoDetailActivity2.this
							.getSystemService(Context.CLIPBOARD_SERVICE);
					// c.setText(smsContent.getText());
					if (videoInfo.getWabSiteUrl() != null
							&& !videoInfo.getWabSiteUrl().equals("")
							&& !videoInfo.getWabSiteUrl().equals("null")) {
						c.setPrimaryClip(ClipData.newPlainText("url",
								videoInfo.getWabSiteUrl()));
					} else {
						c.setPrimaryClip(ClipData.newPlainText("url",
								videoInfo.getVideoUrl()));
					}
					Toast.makeText(PaikeVideoDetailActivity2.this, "复制成功",
							Toast.LENGTH_SHORT).show();
					break;
				}

			}
		});
		// }
		mSharedialog.show();
	}

	/** 个人的视频详情页的更多 */
	private void showMoreLayoutOnSelf() {
		final MyDialog dialogCommon = new MyDialog(this,
				R.style.dialog_headsetting);
		LinearLayout linearlayout;
		android.view.WindowManager.LayoutParams layoutparams;
		linearlayout = (LinearLayout) ((LayoutInflater) this
				.getSystemService("layout_inflater")).inflate(
				R.layout.pop_video_detail_more_onself, null);
		linearlayout.setMinimumWidth(10000);

		layoutparams = dialogCommon.getWindow().getAttributes();
		layoutparams.x = 0;
		layoutparams.y = -1000;
		layoutparams.gravity = 80;
		dialogCommon.onWindowAttributesChanged(layoutparams);

		dialogCommon.setCanceledOnTouchOutside(true);
		dialogCommon.setContentView(linearlayout);
		if (isCollect) {
			((TextView) dialogCommon.findViewById(R.id.tv_collect))
					.setTextColor(getResources().getColor(R.color.color_blue));
		} else {
			((TextView) dialogCommon.findViewById(R.id.tv_collect))
					.setTextColor(getResources().getColor(
							R.color.color_textColor_black_33));
		}
		if (isReport) {
			((TextView) dialogCommon.findViewById(R.id.tv_report))
					.setTextColor(getResources().getColor(R.color.color_blue));
		} else {
			((TextView) dialogCommon.findViewById(R.id.tv_report))
					.setTextColor(getResources().getColor(
							R.color.color_textColor_black_33));
		}
		if (!isHasAlbum) {
			dialogCommon.findViewById(R.id.ll_collect).setVisibility(View.GONE);
		}
		dialogCommon.findViewById(R.id.ll_collect).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						dialogCommon.dismiss();
						// 从专辑中移除
						// new RemoveAlbumAsync().execute();
						getRemoveTheVideoFromAlbum();
					}
				});
		dialogCommon.findViewById(R.id.ll_report).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						dialogCommon.dismiss();
						// 删除本视频
						// new
						// DeleteVideoAsync(scenarioVideoInfo.getVideoId()).execute();
						getDeleteTheVideo(scenarioVideoInfo.getVideoId());
					}
				});
		dialogCommon.findViewById(R.id.ll_cancel).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						dialogCommon.dismiss();
					}
				});
		dialogCommon.show();
	}

	private void showMoreLayout(int index) {
		layoutMoreBack.setVisibility(View.VISIBLE);
		isMoreValue = true;
		if (isCollect) {
			// ((TextView)dialogCommon.findViewById(R.id.tv_collect)).setTextColor(getResources().getColor(R.color.color_text_selected));
			((TextView) findViewById(R.id.tv_collect)).setSelected(true);
			((ImageView) findViewById(R.id.video_more_img_shoucang))
					.setSelected(true);
		} else {
			// ((TextView)dialogCommon.findViewById(R.id.tv_collect)).setTextColor(getResources().getColor(R.color.color_white));
			((ImageView) findViewById(R.id.video_more_img_shoucang))
					.setSelected(false);
			((TextView) findViewById(R.id.tv_collect)).setSelected(false);
		}

	}

	private void hideSoftInput() {
		((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
				.hideSoftInputFromWindow(PaikeVideoDetailActivity2.this
						.getCurrentFocus().getWindowToken(),
						InputMethodManager.HIDE_NOT_ALWAYS);
	}

	/** 打赏相关 */
	boolean isSelect1 = true;
	boolean isSelect5 = false;
	boolean isSelect10 = false;
	boolean isSelectInput = false;
	String videoMoney = "1";

	/**
	 * 
	 */
	private void showRewardDialog() {

		final MyDialog dialogCommon = new MyDialog(this,
				R.style.dialog_headsetting);
		LinearLayout linearlayout;
		android.view.WindowManager.LayoutParams layoutparams;
		linearlayout = (LinearLayout) ((LayoutInflater) this
				.getSystemService("layout_inflater")).inflate(
				R.layout.dialog_rewardmoney_select, null);
		linearlayout.setMinimumWidth(10000);

		layoutparams = dialogCommon.getWindow().getAttributes();
		layoutparams.x = 0;
		layoutparams.y = -1000;
		layoutparams.gravity = 80;
		dialogCommon.onWindowAttributesChanged(layoutparams);

		dialogCommon.setCanceledOnTouchOutside(true);
		// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
		dialogCommon.setContentView(linearlayout);

		final EditText editMoney = (EditText) linearlayout
				.findViewById(R.id.rewardmoney_edit_money);
		final Button btnMoney1 = (Button) dialogCommon
				.findViewById(R.id.rewardmoney_btn_money_1);
		final Button btnMoney5 = (Button) dialogCommon
				.findViewById(R.id.rewardmoney_btn_money_5);
		final Button btnMoney10 = (Button) dialogCommon
				.findViewById(R.id.rewardmoney_btn_money_10);
		btnMoney1.setBackgroundResource(R.drawable.btn_selected_back);
		btnMoney1.setTextColor(getResources().getColor(R.color.white));
		isSelect1 = true;
		isSelect5 = false;
		isSelect10 = false;
		isSelectInput = false;
		videoMoney = "1";
		editMoney.setFocusable(false);
		btnMoney1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				isSelect1 = true;
				isSelect5 = false;
				isSelect10 = false;
				isSelectInput = false;
				videoMoney = "1";
				editMoney.setFocusable(false);
				editMoney.setText("");
				btnMoney1.setBackgroundResource(R.drawable.btn_selected_back);
				btnMoney1.setTextColor(getResources().getColor(R.color.white));
				btnMoney5.setBackgroundResource(R.drawable.btn_select_back);
				btnMoney5.setTextColor(getResources().getColor(
						R.color.color_textColor_black_66));
				btnMoney10.setBackgroundResource(R.drawable.btn_select_back);
				btnMoney10.setTextColor(getResources().getColor(
						R.color.color_textColor_black_66));
			}
		});
		btnMoney5.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				isSelect1 = false;
				isSelect5 = true;
				isSelect10 = false;
				isSelectInput = false;
				videoMoney = "5";
				editMoney.setFocusable(false);
				editMoney.setText("");
				btnMoney1.setBackgroundResource(R.drawable.btn_select_back);
				btnMoney1.setTextColor(getResources().getColor(
						R.color.color_textColor_black_66));
				btnMoney5.setBackgroundResource(R.drawable.btn_selected_back);
				btnMoney5.setTextColor(getResources().getColor(R.color.white));
				btnMoney10.setBackgroundResource(R.drawable.btn_select_back);
				btnMoney10.setTextColor(getResources().getColor(
						R.color.color_textColor_black_66));
			}
		});
		btnMoney10.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				isSelect1 = false;
				isSelect5 = false;
				isSelect10 = true;
				isSelectInput = false;
				videoMoney = "10";
				editMoney.setFocusable(false);
				editMoney.setText("");
				btnMoney1.setBackgroundResource(R.drawable.btn_select_back);
				btnMoney1.setTextColor(getResources().getColor(
						R.color.color_textColor_black_66));
				btnMoney5.setBackgroundResource(R.drawable.btn_select_back);
				btnMoney5.setTextColor(getResources().getColor(
						R.color.color_textColor_black_66));
				btnMoney10.setBackgroundResource(R.drawable.btn_selected_back);
				btnMoney10.setTextColor(getResources().getColor(R.color.white));
			}
		});
		dialogCommon.findViewById(R.id.rewardmoney_edit_money)
				.setOnTouchListener(new OnTouchListener() {

					@Override
					public boolean onTouch(View arg0, MotionEvent arg1) {
						// TODO Auto-generated method stub
						isSelect1 = false;
						isSelect5 = false;
						isSelect10 = false;
						isSelectInput = true;
						editMoney.setFocusable(true);
						editMoney.setFocusableInTouchMode(true);
						btnMoney1
								.setBackgroundResource(R.drawable.btn_select_back);
						btnMoney1.setTextColor(getResources().getColor(
								R.color.color_textColor_black_66));
						btnMoney5
								.setBackgroundResource(R.drawable.btn_select_back);
						btnMoney5.setTextColor(getResources().getColor(
								R.color.color_textColor_black_66));
						btnMoney10
								.setBackgroundResource(R.drawable.btn_select_back);
						btnMoney10.setTextColor(getResources().getColor(
								R.color.color_textColor_black_66));
						return false;
					}
				});
		// 处理输入金额最多输入2位小数
		editMoney.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// TODO Auto-generated method stub
				if (s.toString().contains(".")) {
					if (s.length() - 1 - s.toString().indexOf(".") > 2) {
						s = s.toString().subSequence(0,
								s.toString().indexOf(".") + 3);
						editMoney.setText(s);
						editMoney.setSelection(s.length());
					}
				}
				if (s.toString().trim().substring(0).equals(".")) {
					s = "0" + s;
					editMoney.setText(s);
					editMoney.setSelection(2);
				}

				if (s.toString().startsWith("0")
						&& s.toString().trim().length() > 1) {
					if (!s.toString().substring(1, 2).equals(".")) {
						editMoney.setText(s.subSequence(0, 1));
						editMoney.setSelection(1);
					}
				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub

			}
		});
		dialogCommon.findViewById(R.id.rewardmoney_btn_cancel_back)
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						dialogCommon.dismiss();
					}
				});
		dialogCommon.findViewById(R.id.rewardmoney_btn_submit)
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub

						if (isSelectInput) {
							videoMoney = editMoney.getText().toString();
							if (videoMoney.contains(".")) {
								int index = videoMoney.indexOf(".");
								String moneyRight = videoMoney
										.substring(index + 1);
								if (moneyRight.length() <= 0) {
									ToastAlone.showToast(
											PaikeVideoDetailActivity2.this,
											"请输入有效金额~", 1);
									return;
								}
								if (moneyRight.length() > 2) {
									ToastAlone.showToast(
											PaikeVideoDetailActivity2.this,
											"请输入有效金额~", 1);
									return;
								} else {
									String moneyLeft = videoMoney.substring(0,
											index);
									moneyLeft = removeStartZeroOfMoney(
											moneyLeft, 1);
									Logger.i(TAG, "moneyLeft==" + moneyLeft);
									long money = Long.parseLong(moneyLeft);
									if (money <= 0) {
										if (moneyRight.length() == 1) {
											if (moneyRight.contains("0")) {
												ToastAlone
														.showToast(
																PaikeVideoDetailActivity2.this,
																"请输入有效金额~", 1);
												return;
											}
										} else {
											if (moneyRight.endsWith("0")) {
												if (moneyRight.startsWith("0")) {
													ToastAlone
															.showToast(
																	PaikeVideoDetailActivity2.this,
																	"请输入有效金额~",
																	1);
													return;
												}
											}
										}
									} else {
										if (money > 5000) {
											ToastAlone
													.showToast(
															PaikeVideoDetailActivity2.this,
															"请输入有效金额~", 1);
											return;
										} else if (money == 5000) {
											// if(!moneyRight.equals("00") ||
											// !moneyRight.equals("0")){
											// ToastAlone.showToast(PaikeVideoDetailActivity.this,
											// "请输入有效金额~", 1);
											// return;
											// }
											if (moneyRight.equals("00")) {

											} else if (moneyRight.equals("0")) {

											} else {
												ToastAlone
														.showToast(
																PaikeVideoDetailActivity2.this,
																"请输入有效金额~", 1);
												return;
											}
										}
									}
								}
								Logger.i(TAG, "videoMoney1111111=="
										+ videoMoney);
							} else {
								videoMoney = removeStartZeroOfMoney(videoMoney,
										-1);
								if (videoMoney.length() <= 0) {
									ToastAlone.showToast(
											PaikeVideoDetailActivity2.this,
											"请输入有效金额~", 1);
									return;
								}
								long nVideoMoney = Long.parseLong(videoMoney);

								if (nVideoMoney > 5000) {
									ToastAlone.showToast(
											PaikeVideoDetailActivity2.this,
											"请输入有效金额~", 1);
									return;
								}
							}

							if (videoMoney.length() <= 0) {
								ToastAlone.showToast(
										PaikeVideoDetailActivity2.this,
										"请输入有效金额~", 1);
								return;
							}
							Logger.i(TAG, "videoMoney=" + videoMoney);
						}
						if (!LoginInfo.getInstance().isLogin()) {

							Intent intent = new Intent();
							intent.setClass(PaikeVideoDetailActivity2.this,
									SettingLoginActivity.class);
							intent.putExtra("loginFlag", 2);
							startActivityForResult(intent,
									STATE_RETURN_LOGIN_REWARD);
							dialogCommon.dismiss();
							return;
						}
						openPayActivity(videoInfo.getTitle(), videoMoney,
								videoInfo.getVideoId(), videoInfo.getDetail());
						dialogCommon.dismiss();
					}
				});
		dialogCommon.show();
	}

	/**
	 * 打开打赏订单页
	 * 
	 * @param name
	 * @param money
	 * @param videoId
	 * @param detail
	 */
	private void openPayActivity(String name, String money, String videoId,
			String detail) {
		Intent intent = new Intent();
		intent.setClass(this, PayActivity.class);
		intent.putExtra("name", name);
		intent.putExtra("money", money);
		intent.putExtra("videoId", videoId);
		intent.putExtra("detail", detail);
		startActivity(intent);
	}

	private String removeStartZeroOfMoney(String money, int type) {
		while (money.startsWith("0")) {
			Logger.i(TAG, "money=" + money);
			Logger.i(TAG, "money.length()=" + money.length());
			if (money.startsWith("0")) {
				Logger.i(TAG, "111111");
				if (money.length() <= 1) {
					if (type == -1) {
						money = "";
					} else {
						money = "0";
					}
					break;
				} else {
					money = money.substring(1);
				}
			}
		}
		return money;
	}

	/***
	 * 获取视频详情
	 * 
	 * @param videoId
	 */
	private void getVideoDetail(String videoId) {
		String url = V1VideoHttpApi.QUERY_V1VIDEO_DETAILS4() + videoId + "/devid/"
				+ Constant.DEVICEID + ".mindex.html";
		Logger.i(TAG, "详情页Url =" + url);
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				url, null, PaikeVideoDetailEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							PaikeVideoDetailEntity entity = (PaikeVideoDetailEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								finish();
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								finish();
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									processVideoDetail(entity.getBody(), 0);
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
						finish();
					}
				});
	}

	/***
	 * 获取广告
	 * 
	 * @param videoId
	 */
	private void getVideoAd() {
		String url = Constant.GET_VIDEO_AD_URL + "1"
				+ V1VideoHttpApi.GET_VIDEO_AD_URL_2();
		// String url =
		// "http://app.v1cn/www/mod/mob/ctl/ads/act/getVideoAd/s/1/pcode/010110000/version/4.0.mindex.html";
		Logger.i(TAG, "广告Url =" + url);
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				url, null, VideoAdEntity.class, 0, "PaikeVideoDetailActivity",
				new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							VideoAdEntity entity = (VideoAdEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								layoutVideoAdBack.setVisibility(View.GONE);
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								layoutVideoAdBack.setVisibility(View.GONE);
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null
										&& entity.getBody().getData() != null) {
									if (entity.getBody().getData()
											.getCarousels() != null
											&& entity.getBody().getData()
													.getCarousels().size() >= 1) {
										layoutVideoAdBack
												.setVisibility(View.VISIBLE);
										viewAdv2.setVisibility(View.VISIBLE);
										viewAdv3.setVisibility(View.VISIBLE);
										listCourseInfo = entity.getBody()
												.getData().getCarousels();
										showAdv();
									} else {
										layoutVideoAdBack
												.setVisibility(View.GONE);
									}
								} else {
									// toast(header.getMessage());
									layoutVideoAdBack.setVisibility(View.GONE);
								}

							}
						} else {
							layoutVideoAdBack.setVisibility(View.GONE);
						}
						Message message1 = Message.obtain();
						message1.what = STATE_GET_COMMENT;
						handler.sendMessage(message1);
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
						Message message1 = Message.obtain();
						message1.what = STATE_GET_COMMENT;
						handler.sendMessage(message1);
					}
				});
	}

	/** 通知服务器视频分享了 */
	private void getTheShareToServer(String videoId, String shareContent) {
		String url = V1VideoHttpApi.GET_VIDEO_SHARE_TO_SERVER() + "&devid="
				+ Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("videoId", videoId));
		list.add(new Parameter("comments", shareContent));
		list.add(new Parameter("stype", "1"));
		list.add(new Parameter("userId",
				LoginInfo.getInstance().isLogin() ? LoginInfo.getInstance()
						.getUserId() : "0"));
		list.add(new Parameter("videoJson", ""));
		RequestManager.getInstance().postRequest(PaikeVideoDetailActivity2.this,
				url, list, ResultInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							ResultInfoEntity entity = (ResultInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {

								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}

	/** 从专辑中移除该视频 */
	private void getRemoveTheVideoFromAlbum() {
		String url = V1VideoHttpApi.GET_REMOVE_VIDEO_FROM_ALBUM() + "&devid="
				+ Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("videoId", scenarioVideoInfo.getVideoId()));
		list.add(new Parameter("albumId", albumId));
		RequestManager.getInstance().postRequest(PaikeVideoDetailActivity2.this,
				url, list, AddAlbumForVideoPageInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							AddAlbumForVideoPageInfoEntity entity = (AddAlbumForVideoPageInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {

									if (entity.getBody().getCode() == 0) {
										// 去除专辑成功
										isHasAlbum = false;
										albumId = "";
										// specialLayout.setVisibility(View.GONE);
										// specialTxt.setVisibility(View.GONE);
										// specialViewIcon.setVisibility(View.GONE);
									} else {
									}
									ToastAlone.showToast(
											PaikeVideoDetailActivity2.this,
											entity.getBody().getMsg(), 1);
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}


	/** 对视频点赞 */
	private void getPraiseTheVideo(String videoId) {
		String url = V1VideoHttpApi.GET_VIDEO_TO_PRAISE() + "&devid="
				+ Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("vid", videoId));
		list.add(new Parameter("uid", LoginInfo.getInstance().getUserId()));
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				1, url, list, ResultInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							ResultInfoEntity entity = (ResultInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									if (entity
											.getBody()
											.getResult()
											.getCode()
											.equals(Constant.RESULT_CODE_SUCCESS)) {
										// success
										// Toast toast = new
										// Toast(PaikeVideoDetailActivity.this);
										// View view =
										// View.inflate(PaikeVideoDetailActivity.this,
										// R.layout.toast_praise, null);
										// toast.setView(view);
										// toast.setText("点赞成功");
										// toast.setGravity(Gravity.CENTER, 0,
										// 0);
										// toast.setDuration(0);
										// toast.show();
										Toast toast = Toast.makeText(
												PaikeVideoDetailActivity2.this,
												"点赞成功", 1);
										toast.setGravity(Gravity.CENTER, 0, 0);
										toast.show();
										if (videoInfo.getPraise() == null
												|| videoInfo.getPraise()
														.equals("")) {
											videoInfo.setPraise("1");
										} else {
											videoInfo.setPraise(String.valueOf(Integer
													.parseInt(videoInfo
															.getPraise()) + 1));
										}
										// isPraised = true;

										String praiseNum = videoInfo
												.getPraise();
										if (praiseNum != null) {
										}
									} else {
										// fails
										toast("点赞失败");
									}
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}

	/** 写评论信息 */
	private void getWriteCommentOfTheVideo(String videoId, String content) {
		String url = V1VideoHttpApi.GET_VIDEO_WRITE_COMMENT() + "&devid="
				+ Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("vid", videoId));
		list.add(new Parameter("uid", LoginInfo.getInstance().getUserId()));
		// list.add(new Parameter("uid", "47"));
		list.add(new Parameter("comments", content));
		list.add(new Parameter("replyUserId", ""));
		RequestManager.getInstance().postRequest(PaikeVideoDetailActivity2.this,
				url, list, VPaikeCommentListInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							VPaikeCommentListInfoEntity entity = (VPaikeCommentListInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									if (entity
											.getBody()
											.getResult()
											.getCode()
											.equals(Constant.RESULT_CODE_SUCCESS)) {
										// getTheVideoComment(videoId, curPage);
										editComment.setText("");
										hideSoftInput();
										toast("您的评论已提交成功~");
										Message message1 = Message.obtain();
										message1.what = STATE_GET_COMMENT;
										handler.sendMessage(message1);
									} else {
										toast(entity.getBody().getResult()
												.getMessage());
									}
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}

	/** 查询视频评论信息 */
	private void getTheVideoComment(String videoId,final int curPage) {
		String url = V1VideoHttpApi.GET_QUERY_VIDEO_COMMENTS() + "&devid="
				+ Constant.DEVICEID + "&vid=" + videoId + "&p=" + curPage;
		if (videoId == null || videoId.length() <= 0) {
			return;
		}
		// ParamList list = new ParamList();
		// list.add(new Parameter("vid", videoId));
		// list.add(new Parameter("p", ""+curPage));
		Logger.i(TAG, "评论获取评论url==" + url);
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				1, url, null, VPaikeCommentListInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());
						if (commentPlv != null) {
							commentPlv.onRefreshComplete();
						}
						if (object != null) {
							VPaikeCommentListInfoEntity entity = (VPaikeCommentListInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								layoutComTipsBack.setVisibility(View.VISIBLE);
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								layoutComTipsBack.setVisibility(View.VISIBLE);
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									Logger.i(TAG, "查询评论信息有返回了");
									//
									if (entity.getBody().getComments_list() != null) {
										if (curPage == 0) {
											infos = entity.getBody()
													.getComments_list();
										} else {
											infos.addAll(entity.getBody()
													.getComments_list());
										}
										// txtNumComment.setText(entity.getBody().getTotal());
										txtNumComment.setText("("
												+ entity.getBody().getTotal()
												+ "条)：");
									} else {
										infos = new ArrayList<VPaikeCommentInfo>();
									}
									int total = 0;
									if (entity.getBody().getTotal() != null
											|| entity.getBody().getTotal()
													.length() > 0) {
										total = Integer.parseInt(entity
												.getBody().getTotal());
									}
									if (infos != null && !infos.isEmpty()) {
										Logger.i(TAG, "评论信息有返回了且评论数据不为空");
										// layoutCommentTitleBack.setVisibility(View.VISIBLE);
										txtNumComment
												.setVisibility(View.VISIBLE);
										txtCommentTip.setText("评论");
										commentVo.clear();
										commentVo.addAll(infos);
										// for (int i = 0; i < infos.size();
										// i++) {
										// Logger.i(TAG, "commentVo.name="
										// + commentVo.get(i).getUserName());
										// }
										commentAdapter.notifyDataSetChanged();
										if (infos.size() < total) {
											commentPlv
													.setMode(Mode.PULL_UP_TO_REFRESH);
										} else {
											commentPlv.setMode(Mode.DISABLED);
										}
										layoutComTipsBack
												.setVisibility(View.GONE);
									} else {
										commentPlv.setMode(Mode.DISABLED);
										layoutComTipsBack
												.setVisibility(View.VISIBLE);
									}
								} else {
									// toast(header.getMessage());
									layoutComTipsBack
											.setVisibility(View.VISIBLE);
								}
							}
						}
						Message message1 = Message.obtain();
						message1.what = STATE_GET_COMMENT_AUTHOR;
						handler.sendMessage(message1);
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
						Message message1 = Message.obtain();
						message1.what = STATE_GET_COMMENT_AUTHOR;
						handler.sendMessage(message1);
						if (commentPlv != null) {
							commentPlv.onRefreshComplete();
						}
					}
				});
	}

	/** 取消收藏视频 */
	private void getCancellCollectionTheVideo(String videoId) {
		String url = V1VideoHttpApi.GET_CANCELL_COLLECTION_VIDEO() + "&devid="
				+ Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("vid", videoId));
		list.add(new Parameter("stype", "1"));
		list.add(new Parameter("uid", LoginInfo.getInstance().getUserId()));
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				1, url, list, ResultInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							ResultInfoEntity entity = (ResultInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									closeMoreLl();
									if (entity
											.getBody()
											.getResult()
											.getCode()
											.equals(Constant.RESULT_CODE_SUCCESS)) {
										isCollect = false;
										mIvCollection.setImageResource(R.drawable.second_collect);
										new_toast = Utils.showtoast(
												PaikeVideoDetailActivity2.this,
												"取消收藏", 1);
									} else {
										// fails
										new_toast = Utils.showtoast(
												PaikeVideoDetailActivity2.this,
												entity.getBody().getResult()
														.getMessage(), 1);
										
									}
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}

	private Toast new_toast;
	private TextView tv_source;
	private String source_name;
	/** 视频收藏 */
	private void getCollectionTheVideo(String videoId) {
		String url = V1VideoHttpApi.GET_COLLECTION_VIDEO() + "&devid="
				+ Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("vid", videoId));
		list.add(new Parameter("stype", "1"));
		list.add(new Parameter("uid", LoginInfo.getInstance().getUserId()));
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				1, url, list, ResultInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							ResultInfoEntity entity = (ResultInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									closeMoreLl();
									if (entity
											.getBody()
											.getResult()
											.getCode()
											.equals(Constant.RESULT_CODE_SUCCESS)) {
										isCollect = true;
										mIvCollection.setImageResource(R.drawable.second_collect_press);
										new_toast = Utils.showtoast(
												PaikeVideoDetailActivity2.this,
												"收藏成功", 1);
									} else {
										// fails
										new_toast =Utils.showtoast(
												PaikeVideoDetailActivity2.this,
												"收藏失败", 1);
									}
								} else {
									toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}

	/** 视频举报 */
	private void getReportTheVideo(String videoId) {
		String url = V1VideoHttpApi.GET_VIDEO_TO_REPORT() + "&devid="
				+ Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("vid", videoId));
		list.add(new Parameter("stype", "1"));
		list.add(new Parameter("uid", LoginInfo.getInstance().getUserId()));
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				1, url, list, ResultInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							ResultInfoEntity entity = (ResultInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									closeMoreLl();
									if (entity
											.getBody()
											.getResult()
											.getCode()
											.equals(Constant.RESULT_CODE_SUCCESS)) {
										isReport = true;
										new_toast =Utils.showtoast(
												PaikeVideoDetailActivity2.this,
												"举报成功", 1);
									} else {
										// fails
										new_toast = Utils.showtoast(
												PaikeVideoDetailActivity2.this,
												entity.getBody().getResult()
														.getMessage(), 1);
									}
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}

	/** 查询视频是否被举报 */
	private void getQueryTheVideoReported(String videoId) {
		String url = V1VideoHttpApi.GET_QUERY_VIDEO_REPORTED() + "&devid="
				+ Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("vid", videoId));
		list.add(new Parameter("stype", "1"));
		list.add(new Parameter("uid", LoginInfo.getInstance().getUserId()));
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				1, url, list, VideoReportInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							VideoReportInfoEntity entity = (VideoReportInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									if (Constant.RESULT_CODE_SUCCESS
											.equals(entity.getBody()
													.getResult().getCode())) {
										if ("0".equals(entity.getBody()
												.getState())) {// 未举报
											isReport = false;
										} else {// 已举报
											isReport = true;
										}
									} else {
										// fails
										// ToastAlone.showToast(PaikeVideoDetailActivity.this,
										// "查询举报"
										// +
										// entity.getBody().getResult().getMessage(),
										// 1);
									}
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}

	/** 查询视频是否收藏 */
	private void getQueryTheVideoCollection(String videoId) {
		String url = V1VideoHttpApi.GET_QUERY_VIDEO_COLLECTED() + "&devid="
				+ Constant.DEVICEID + "&vid=" + videoId + "&uid="
				+ LoginInfo.getInstance().getUserId();
		// ParamList list = new ParamList();
		// list.add(new Parameter("vid", videoId));
		// list.add(new Parameter("uid", LoginInfo.getInstance().getUserId()));
		Logger.i(TAG, "收藏url==" + url);
		RequestManager.getInstance().getRequest(PaikeVideoDetailActivity2.this,
				1, url, null, VideoCollectionInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());
						if (object != null) {
							VideoCollectionInfoEntity entity = (VideoCollectionInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									if (Constant.RESULT_CODE_SUCCESS
											.equals(entity.getBody()
													.getResult().getCode())) {
										if ("0".equals(entity.getBody()
												.getState())) {// 未收藏
											isCollect = false;
											mIvCollection.setImageResource(R.drawable.second_collect);
										} else {// 已收藏
											isCollect = true;
											mIvCollection.setImageResource(R.drawable.second_collect_press);
										}
									} else {
										// fails
										// ToastAlone.showToast(PaikeVideoDetailActivity.this,
										// "查询收藏"
										// +
										// entity.getBody().getResult().getMessage(),
										// 1);
									}
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}

	/**
	 * 删除视频
	 * 
	 * @param videoId
	 */
	private void getDeleteTheVideo(String videoId) {
		String url = V1VideoHttpApi.GET_DELETE_VIDEO() + "&devid=" + Constant.DEVICEID;
		ParamList list = new ParamList();
		list.add(new Parameter("videoId", videoId));
		list.add(new Parameter("deleteType", "release"));
		Logger.i("url", "详情页删除url=" + url);
		Logger.i(TAG, "详情页删除videoId=" + videoId);
		RequestManager.getInstance().postRequest(PaikeVideoDetailActivity2.this,
				url, list, ResultInfoEntity.class, 0,
				"PaikeVideoDetailActivity", new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String key) {
						// TODO Auto-generated method stub
						Logger.i(TAG, "onSuccess.object=" + object.toString());

						if (object != null) {
							ResultInfoEntity entity = (ResultInfoEntity) object;
							com.v1.video.domain.BaseEntity.Header header = entity
									.getHeader();
							if (header == null) {
								toast("未知错误~");
								return;
							} else if (!header.getStatus().equals("1")) {
								toast(header.getMessage());
								return;
							} else if (header.getStatus().equals("1")) {
								if (entity.getBody() != null) {
									if (entity.getBody().getResult().getCode()
											.equals("0")) {
										finish();
										toast(entity.getBody().getResult()
												.getMessage());
									} else {
										toast(entity.getBody().getResult()
												.getMessage());
									}
								} else {
									// toast(header.getMessage());
								}
							}
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.i(TAG, message);
					}
				});
	}
	
	public void showSendCommentDialog(String id, String nickname) {
		if (LoginInfo.getInstance().isLogin()) {
			if (mCommentEditFragment == null) {
				mCommentEditFragment = new CommentEditFragment(this,
						new CommentDataCallBack() {
							@Override
							public void notifyData() {
								if (videoInfo != null) {
									mCurIndex = 0;
									mLastId = "0";
									getCommentData(videoInfo.getVideoId());
								}
							}

							@Override
							public String getObjectId() {
								if (videoInfo != null) {
									return videoInfo.getVideoId();
								}
								return "";
							}

							@Override
							public String getObjectName() {
								if (videoInfo != null) {
									return videoInfo.getTitle();
								}
								return "";
							}
						});
			}
			mCommentEditFragment.showCommentDialog(id, nickname,
					Constant.COMMENT_VIDEO_TYPE);
		} else {
			mCommentId = id;
			mReplyName = nickname;
			transferLogin(Constant.REQUEST_COMMENT_CODE);
		}
	}
	
	private void transferLogin(int requestCode) {
		Intent intent = new Intent(this, SettingLoginActivity.class);
		intent.putExtra("loginFlag", 2);
		startActivityForResult(intent, requestCode);
	}

	public void gotoOtherPersonHome(String userId, String nickName,
			String userSex, String isCertification, String userHead,
			String userDesc, String focousType) {
		Intent intent = new Intent();
		intent.setClass(PaikeVideoDetailActivity2.this,
				OtherPersonHomeActivity.class);
		intent.putExtra("userId", userId);
		intent.putExtra("nickName", nickName);
		intent.putExtra("userSex", userSex);
		intent.putExtra("isCertification", isCertification);
		intent.putExtra("userHead", userHead);
		intent.putExtra("userDesc", userDesc);
		intent.putExtra("focousType", focousType);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		vv_video.pause();
		PaikeVideoDetailActivity2.this.startActivity(intent);

		// PaikeVideoDetailActivity.this.finish();
	}

	private void videoPlayUpToServer(String flag, String time) {
		if (scenarioVideoInfo != null
				&& !TextUtils.isEmpty(scenarioVideoInfo.getVideoId())) {
			if (TextUtils.isEmpty(mSource)) {
				mSource = Constant.ADV_SOURCE_OTHER;
			}
			new NetEngine().videoPlayUpToServer(PaikeVideoDetailActivity2.this,
					mUuid, LoginInfo.getInstance().getUserId(),
					scenarioVideoInfo.getVideoId(), mSource, flag, time);
		}
	}
	
	private void getCommentData(String vid) {
		new NetEngine().getCommentData(this, vid, mLastId,
				Constant.COMMENT_VIDEO_TYPE, Constant.COMMENT_TIME_SORT,
				new OnResponseListener() {

					@Override
					public void onSuccess(Object object, int code,
							String message, String keyId) {
						// TODO Auto-generated method stub
						commentPlv.onRefreshComplete();
						try {
							if (object != null) {
								CommentEntity entity = (CommentEntity) object;
								if (entity != null
										&& entity.getBody() != null
										&& entity.getBody().getComments_list() != null
										&& entity.getBody().getComments_list()
												.size() > 0) {
									mLastId = entity.getBody().getLast_id();
									if (mAdapter != null) {
										if (mCurIndex == 0) {
											if(entity.getBody()
													.getComments_list()!= null && entity.getBody()
													.getComments_list().size()>0){
												txtNumComment.setText(entity.getBody()
															.getComments_list().size() + "");
												}
											commentAdapter.getDataLst().clear();
										}
										commentAdapter.setDataList(entity
												.getBody().getComments_list());
									}
									int total = (mCurIndex + 1)
											* Constant.COMMENT_PAGE_SIZE;
									if (total < entity.getBody().getTotal()) {
										mCurIndex++;
										if (commentPlv != null) {
											commentPlv
													.setMode(PullToRefreshBase.Mode.BOTH);
										}
									} else {
										if (commentPlv != null) {
											commentPlv
													.setMode(PullToRefreshBase.Mode.DISABLED);
										}
									}
								} else {
									if (commentAdapter != null) {
										commentAdapter.setNoComment(true);
									}
								} 
							} else {
								if (commentAdapter != null) {
									commentAdapter.setNoComment(true);
								}
							}
						} catch (Exception ex) {
							ex.printStackTrace();
						}
					}

					@Override
					public void onFailure(int code, String message) {
						// TODO Auto-generated method stub
						Logger.e(TAG, message);
					}

				});
	}
}
